Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
H13 (connection closed with no response) from Puma on Heroku #1802
For full description see reproduction repository https://github.com/schneems/puma_connection_closed_reproduction.
Possible cause and fix
It looks like durring SIGTERM the socket connection is never explicitly closed. The only way it is closed is when the process calls
The H10s are expected? You've got .01 seconds between the log line acking the SIGTERM and the H13. Did it H13 because the worker died? Was that an already inflight request and we've got problems with Puma not allowing draining? What's the Heroku forced kill situation look like i.e. if I trap a SIGTERM and do nothing, at what point would you come in and kill the dyno and is that a factor here?
Heroku gives a process 10 seconds to shut down before sending a SIGKILL.
If you’re running my reproduction the reason a H10 happens is because the main process died so Heroku reports it as “crashed” https://devcenter.heroku.com/articles/error-codes#h10-app-crashed. This is because we are sending ourselves a sigterm versus the platform sending us one.
I think the H13 comes because even though the worker is dead and cannot process requests, the socket is still open and accepted a request that it could not respond to. It only closes the connection when the main process exits via an exit() call.