Repository navigation
[fix] Stop a silent admin connection from stalling shutdown - #15
Merged
Merged
Conversation
server.close() waits for every open socket, and one that connected without ever sending a request is not idle to Node, so a browser's speculative connection made every stop take the full 15s timeout and exit 1. Close all admin connections once the server stops listening.
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.
The bug
On a live StartOS box every stop of the relay logged
shutdown timed out — exitingand the process exited 1 after exactly 15 seconds.admin.close()wasserver.close(resolve), which waits for every open socket. Node's idle-connection sweep only covers sockets that have completed a request, so a connection that was opened and never used — which browsers and platform proxies create speculatively all the time — held the close open until the shutdown timer fired.stopRelayawaits the admin server first, so the DHT node was never closed cleanly either.Reproduced against a real process: with one silent TCP connection to the admin port,
SIGTERMexited 1 after 15005 ms. A keep-alive connection that had sent a request did not reproduce it.The fix
Call
server.closeAllConnections()right afterserver.close(). At shutdown there is nothing on the read-only admin surface worth waiting for.With the fix the same reproduction exits 0 in about 270 ms.
Testing
admin-http.test.js, red before the fix: opens a silent socket, waits until the server has accepted it, and assertsstop()completes. It races a timer so a regression is an assertion, not a hung suite.npm run lintclean,npm test402/402..claude/lessons.md.