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
Race condition bug loading manifest #2324
Comments
Do you allow webpacker time to compile your packs? It looks like you started your tests in the middle of webpacker compiling when the content of manifest.json isn't present. |
This isn't me doing it, it's rails I think the solution would be to write the file in a temp location, then atomically move it to the manifest when it is written, or some other threadsafe locking mechanism as it seems that webpacker assumes that because the file exists, it has been written. The webpacker code when reading, just checks that the file exists. So I would say this part of webpacker isn't threadsafe / parallel safe. |
In the reading part of webacker the following code makes the assumption that if the file exists, it's good to parse. But I don't think the writing code can give any such guarantees. if config.public_manifest_path.exist?
JSON.parse config.public_manifest_path.read |
Are several instances of webpacker run in parallel, or do the tests start after the packs are compiled? |
@jakeNiemiec I assume the former else the issue wouldn't happen. |
Could I trouble you to make a repro? |
I'm not sure that's needed as the code in question isn't my code, it's in rails itself. I think the issue is clear - |
Hi, |
Just left a commend in the linked Rails issue (rails/rails#37472). TLDR, try upgrading both the webpacker and json gems. |
I can't, but I would be happy to walk through it with you if you post an example of what is going wrong.
|
@jakeNiemiec I literally meant the json and webpacker gems. After I upgrade both of their versions, I was no longer experiencing this bug. |
For someone getting here through search engine. I had a similar situation with Rails 6. All my system tests passes on local, but several fails on Semaphore CI frequently. The errors are
It look likes caused by webpacker, so I do some search work, it takes some time to bring me here. As far as I know, Rails 6 enable parallel tests by default. I don't have many systems tests, so my solution is to reduce parallel |
This race condition is still here. See #2860 for explanation and a (cleaner) workaround. |
Not sure if this is a webpacker or rails bug, but please see rails/rails#37472
If the manifest code is run in multiple threads / parallel - is it possible it can be writing to and reading from the same manifest file at the same time?
The text was updated successfully, but these errors were encountered: