Uh oh!
There was an error while loading. Please reload this page.
Tell the client the connection is closing after each response - #212
Open
arpitjain099 wants to merge 1 commit into
Open
Tell the client the connection is closing after each response#212arpitjain099 wants to merge 1 commit into
arpitjain099 wants to merge 1 commit into
Conversation
Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
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 freeto 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.
Fixes#211.
handleHTTPConnectionandhandleTLSConnectioneach read one request and close the connection in a defer, but neither response says so. The upstreamConnection: keep-aliveis not passed through either, so a client that pools sockets, Node'shttps.Agent({keepAlive: true})in the report, keeps the socket and the next write lands on a connection the proxy has already gone away from. That is the alternatingsocket hang upin the issue, and it is whycode-server --install-extensionfails outright andnpm installcrawls.RFC 9112 section 9.6 puts that on the sender: if you are going to close, say so. The forwarded response now drops any upstream
Connectionheader and setsresp.Close, soResponse.WriteemitsConnection: close, and the blocked 403 does the same.This is the first of the two options in the issue. Actually keeping connections alive, the second option, is the better outcome for throughput, but it means holding the connection open and looping over requests in both handlers, which is a larger change and a design call for you rather than something to slip into a bug fix.
The test starts a local backend, goes through the proxy for one allowed and one blocked request, and asserts
resp.Closeon both. It fails on main with "response must tell the client the connection is closing".go test -race ./proxy/passes.