Hello,
I’ve just had a miserable time using byebug within Discourse, due to the default worker_processes
being set to 3 in unicorn.conf.rb
.
If multiple web workers get stopped by byebug at the same time (for example, you put a byebug line in the drafts#show
route, and hit that route twice during the course of development), you end up in a situation where byebug is unable to determine which process you’re typing input for. So, for example, with one stopped process you may type
(byebug) continue
to continue execution, but with two stopped processes you get
(byebug) continue
*** NameError Exception: undefined local variable or method `cntne' for #<Class>
Even doubling up your input doesn’t really seem to work either:
(byebug) ccoonnttiinnuuee
*** NameError Exception: undefined local variable or method `cntinnue' for #<Class>
This leads to needing to shut down the server completely in order to continue, and happens every time multiple requests are halted by a byebug at once (which, for certain routes, can be quite often)
(NB that this behaviour happens with binding.pry as well)
The workaround is to run
UNICORN_WORKERS=1 bin/unicorn -p 3000
or otherwise set your UNICORN_WORKERS ENV to 1 before booting the app.
I think this could be byebug’s problem (I’ve filed a issue about it), but I wonder what the downsides would be of setting the worker count to 1 automatically in development?