-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Problematic shutdown when using ActionController::Live #938
Comments
Yes, this an existing issue that I haven't figured out the right way to fix. Puma wants to wait until all the requests are done before shutting down but the Live is just sitting there waiting and thus never shuts down. Part of the issue is that Puma doesn't know that request is Live-style connection. |
Thanks for confirming @evanphx, I suspected as much! Would you be open to making this behavior:
configurable? Perhaps we could set a boolean like I think this would skirt the issue of Puma having to somehow detect that we expect long-lived requests (because we’d be responsible for setting the setting), but it would allow us to use Puma in these scenarios also. |
I can certainly give you an option to perform an unclean shutdown, sure. Perhaps Would that work for you? |
@evanphx I think that would work well! However, would it be possible to just kill the threads (thus unblocking the shutdown procedure which waits on them, and allowing it to continue) instead of calling I think that would cause less compatibility trouble (if someone has exit handlers they could still run, just the HTTP-serving threads would get killed abruptly), but I am not very familiar with Puma’s code in this area, so sorry if this is a dumb question! |
@vandrijevik I can have it try to kill the threads, though I still consider that a dicey move because it introduces the equivalent of raising an exception in a random place, and it doesn't work if the code is blocked in some C code (sometimes). |
Thank you @evanphx! 😄 |
Hello!
I am trying to use
ActionController::Live
in Rails to implement an application which uses server-sent events to send data to the browser. I find that doing so breaks the shutdown procedure for Puma (which never shuts down while there is a connection open from a browser), and I believe the problem is with Puma’s waiting on threads which serve connections to finish.I have created a sample app, located at https://github.com/vandrijevik/sse_relay/ to demonstrate the issue, and compare it with using Rainbows!, which does what I would expect. The README in that repo contains instructions on how to replicate the problem, so I am not copying them here.
There are a few related issues in this repository:
and in particular, back in 2013 @evanphx asked:
In this case yes, that is exactly what I expect to happen.
I opted to create a new issue since I could not clearly understand the specific problem from the above-mentioned ones, and none of them seemed to include code suitable for easy reproduction.
There is a potentially related issue in Rails as well, rails/rails#10989. That issue is from 2013, so it is quite stale by now, but since it is currently open, and no one answered @tenderlove’s ask for a sample application, I am cross-referencing it here in the hopes that this may be helpful.
For reference, I am using:
Thanks for considering this!
The text was updated successfully, but these errors were encountered: