-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix postProcessors race condition #54
Fix postProcessors race condition #54
Conversation
- Check for postProcessor bundles to be finished before writing assetsRequiredByEntryPoint to metaData.json - Test case for postProcessor race condition - Code consolidation for async parallel tasks
hey @dgbeck, can you please check this PR? This problem is kind of blocking us. Thanks! |
Hi @hershmire and @ferlores thanks for the thorough write up and the PR. I looked at this a bit today and it looks good. I'd just like to take some more time to review it before merging and also would like to test it using a large project to make sure nothing breaks. I will get to this by early next week if not sooner. Thanks! |
Thanks @dgbeck! Any progress on taking a closer look at the PR and testing on a larger project? |
Hi @hershmire , yes we are making progress. Looking good, will update you later today. |
Hi @hershmire this is a great find. Thank you very much for reporting this issue and for the very clear explanation and also the new test, which made it very easy to reproduce. As we started to review this PR we took a step back and see if there is a way to simplify the way we were handling these async post processing operations. Also, we have been considering adding support for a css common bundle, as suggested in #48, and did some refactoring with that eventual goal in mind. The result is this PR. We took the async stuff out of the Can you check out #55 and confirm it is working for your use case as well? I can then merge to master and do a patch release. Thank you very much for identifying and helping resolve this issue! |
@dgbeck Awesome, everything seems to work as expected on our end! I think we're a go. When could we have a patch published to NPM? |
published @6.2.1. Thanks again @hershmire ! |
👍 |
The Problem
When adding a CSS post processor to Cartero's
postProcessors
option, I get a race condition where Cartero writes to theassetsRequiredByEntryPoint
object of the metaData.json file prior to the CSS post process stream finishing. Since Cartero only checks that all the entry point JS bundles and parcelifydone
event is called, there is sometimes a chance for a post processed stream to finish too late, resulting in empty arrays for required assets.To easily simulate this, I've added a dummy postProcessor stream with a
setTimeout()
(part of test case) to delay the ending of the stream.metaData.json
Before FixNote:
assetsRequiredByEntryPoint.page1/page1.js
'sstyle
array should not be empty. However, thestyle
andimage
arrays for thepage2/page2.js
's object is correct since I don't have any css or images in there.metaData.json
After FixNote: The
style
array is now correct forpage1/page1.js
:Solution
Add an additional check to make sure any postProcessor parcels are finished before writing to metaData.json.
Changes