rails test:system race condition(?) with webpacker Ruby
Steps to reproduce
1) Use webpacker
2) Have 4+ system tests
Occasionally will get a JSON Parse error from trying to load the manifest resulting in the system tests failing.
Workaround / Fix
Not sure if this is a webpacker bug or a rails system tests bug.
I believe the following monkeypatch proves that it is a race condition as it fixes the issue.
puts "Webpacker JSON Parse error!"
In my tests I now get
"Webpacker JSON Parse error!" coming up occasionally.
Webpacker issue: https://github.com/rails/webpacker/issues/2324
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails team are limited, and so we are asking for your help.
If you can still reproduce this error on the
6-0-stable branch or on
master, please reply with all of the information you have about it in order to keep the issue open.
Thank you for all your contributions.
I was also running into what I believe was a race condition in my tests that rely on Webpacker. Basically, I would call
Webpacker.compile before the test suite to build assets and then execute the test cases (rspec capybara tests). But, I would keep getting back a return value of
false from the
#compile method, suggesting that compilation was not working. However, I could confirm via direct executions of
bin/webpack that there wasn't actually anything wrong with the Webpack build itself. I also did not see this behaviour on my app's CI Pipeline.
I deduced that it was a race condition causing a problem because, while debugging the issue, I places a
puts line directly into the Webpacker gem code. Suddenly, compilation before the test suite would work again. Did flushing the STDOUT stream with
puts cause enough of a delay to workaround a race condition?
From looking at the stack trace above, I made a deduction that perhaps my JSON gem was too old....and lo and behold, it was a few years old. So, after upgrading
json from 2.1.0 to 2.3.0 (and also
webpacker from 4.0.7 to 4.2.2), the problem has gone away for good. So....maybe try upgrading old dependencies?
FWIW my project is still on Rails 5.2.
So, this is definitely a race condition in Webpacker. See https://github.com/rails/webpacker/issues/2860 for a correct workaround.
- openemr UuidMapping registry for vital records creates extremely slow API requests - PHP
- Routing key handling - PHP RabbitMqBundle
- Docker setup pgpass file - OpenSlides
- ipsec协商失败,请大佬解惑 - Shell setup-ipsec-vpn
- Reload the left view table - Swift LGSideMenuController
- transmission A use-after-free bug in concurrent environment C++
- unable connect to other instances - Ruby mastodon