Closed dkobia closed 5 years ago
To be fair a similar problem is mentioned at Rails: https://github.com/rails/rails/issues/32451
Thanks so much for the report! This is probably what is going on with #281 and #280 also.
I'm currently able to get around this by commenting out Jets::Autoloaders.main.reload if Jets.env.development?
in lib/jets/controller/base.rb
. Just means development will be painful. Digging into it further I came across this ticket at Zeitwerk: https://github.com/fxn/zeitwerk/issues/52
@dkobia This is helpful!
Was able to reproduce the error with curl:
for i in {1..2} ; do echo $i ; curl localhost:8888/posts & done
I was actually looking at the same technique in the https://github.com/fxn/zeitwerk/issues/52 issue to fix the issue.
For some reason the @mutex.synchronize
is not "locking" the request and processing in serial. Another request starts before the other request has finished:
Maybe am not using the Mutex correctly 🤔
@dkobia Figured it out. Needed to use a global variable for the mutex otherwise the mutex was a brand new one every request. Released in v1.9.11
@tongueroo ... very nicely done!
Checklist
jets upgrade
command that makes this a simple task. There's also an Upgrading Guide: http://rubyonjets.com/docs/upgrading/My Environment
Expected Behaviour
Execute two concurrent
GET
request to Jets API in development for demo project should yield valid responses.The reason this is a problem is because we're testing an app on local that makes concurrent requests (2) and one always comes back with an error.
Current Behavior
I'm not sure if this is by design or not but if I execute two or more concurrent requests to a Jets API I get
uninitialized constant XXXX
errors to random classes.Step-by-step reproduction instructions
curl http://localhost:8888/posts & curl http://localhost:8888/posts
uninitialized constant PostsController::Post
Code Sample
Solution Suggestion