Repository navigation
feat: let HTTP stop() wait for the requests in flight [draft] - #9
Merged
Merged
Conversation
server.stop({ timeoutMs }) stops accepting new connections, then waits until
no request is in flight or timeoutMs passes, and only then closes all
connections. Without timeoutMs, stop() works as before.
Node's server.close() already lets the running requests complete. Instead of counting the requests, stop() now calls closeAllConnections() only after timeoutMs, if connections are still open.
hmvs
marked this pull request as draft
November 25, 2026 01:06
stopServer() now uses one timer for both cases: closeAllConnections() runs after timeoutMs (0 by default) and the timer is cleared when the server has closed. Removed two tests that did not check allserver's own behaviour.
hmvs
marked this pull request as ready for review
November 25, 2026 01:17
koresar
approved these changes
Nov 25, 2026
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.
Today
HttpTransport.stopServer()callscloseAllConnections()right afterclose(), so every request still running when a service gets SIGTERM loses its connection. The caller gets an error and cannot know whether the work was done. The gRPC and BullMQ transports already wait.server.stop({ timeoutMs }): Node'sserver.close()stops new connections and lets running requests complete;closeAllConnections()runs only aftertimeoutMsif connections are still open.keepAliveTimeout(5s by default), sostop()can take up to that much longer than the slowest request.stop()without options still closes all connections at once (now about 1 ms afterclose(), through the same timer), so this can ship as a minor release (2.7.0).