fix(hono-server): drain in-flight requests on shutdown (P1-3)#1587
Merged
Conversation
Verification reframed the launch-readiness P1-3 finding: the kernel already handles SIGINT/SIGTERM/SIGQUIT with an ordered, 60s-bounded graceful shutdown (registerShutdownSignals + performShutdown + onShutdown hooks), and serve.ts boots through it — so "no signal handling" was a false positive. The real, narrower bug: HonoHttpServer.close() called closeAllConnections(), force-killing in-flight requests. Now it drains: server.close() + drain active, closeIdleConnections() to release idle keep-alive, and a bounded drain window (default 10s, < kernel 60s) force-closes only stragglers so shutdown can't hang. +2 integration tests (drain completes a slow request; force-close bounds a hung one). docs/launch-readiness.md P1-3 updated with the verification finding. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses launch-readiness P1-3. Verifying it first (per the checklist) flipped most of the finding:
Verification: "no SIGTERM/SIGINT handling" is a false positive
The kernel already does coordinated graceful shutdown:
Kernel.registerShutdownSignals()(called at start) handles SIGINT / SIGTERM / SIGQUIT →shutdown()→performShutdown(): ordered plugin destroy (reverse),kernel:shutdownhook, thenonShutdownhandlers.shutdownTimeout(the ≥60s grace floor the action asked for already exists).cli/serve.tsboots through the kernel, so production inherits all of this.The real, narrower bug — fixed
The standalone Hono server's
close()calledcloseAllConnections(), which force-terminated in-flight requests mid-response. So a SIGTERM during a rolling deploy did drop active requests — but because of this, not missing signal handling.Now
close()drains:server.close()— stop accepting new connections, let active requests finish.closeIdleConnections()— release idle keep-alive sockets so the process exits promptly (notcloseAllConnections, which kills active ones).Tests
+2 integration tests (real ephemeral-port server): a slow request completes through
close()(drained, not reset); a hung request is force-closed within the drain window (shutdown doesn't wait it out).plugin-hono-server40 tests green.Residual (noted in the doc, not blocking)
kernel.onShutdown(...)by the cluster plugin — worth a quick confirm.🤖 Generated with Claude Code