Should stopping gracefully also destroy idle sockets?#27
Open
davesteinberg wants to merge 1 commit intohunterloftis:masterfrom
Open
Should stopping gracefully also destroy idle sockets?#27davesteinberg wants to merge 1 commit intohunterloftis:masterfrom
davesteinberg wants to merge 1 commit intohunterloftis:masterfrom
Conversation
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.
I'm trying to use stoppable to shutdown a server gracefully, but I've been stymied by an extra unused connection that Chrome seems to open.
Here's a simple server that illustrates the problem (adapted from
test/server.js):If I start the server with, say, a 5-second grace, then I get
localhost:8080in Chrome, then immediately press Ctrl-c to stop the server, I observe that it waits 5 seconds before it actually stops.I sprinkled some
console.logs throughstoppable.jsand discovered that Chrome (I'm using 85.0.4183.83 on macOS) is actually connecting twice, and even though stoppable is callingend()on both sockets, thecloseevent is only firing once. After the 5 second grace timeout, it finally callsdestroy(), which actually kills the second connection and allows the server to stop. I guess Chrome is being a bad citizen and ignoring the FIN sent byend()? I've tried with Firefox and httpie, and they don't have this problem (and they don't make a second connection in the first place).What's strange is that I would expect the same problem using
test/server.js, but it doesn't happen there. There are still two connections, but they both close properly. Any idea why?In any case, my idea is that it might make sense to be more aggressive about what stoppable considers "graceful", by actually calling
destroy()on idle sockets, as well. I tried making the change (this PR) and it solves my problem. All the tests still pass, too.Any thoughts?