Repository navigation
tls: stop emitting data after ReadStop() - #67676
Open
barathraj048 wants to merge 1 commit into
Open
barathraj048 wants to merge 1 commit into
barathraj048 wants to merge 1 commit into
Conversation
When JS calls ReadStop() on a TLS socket, TLSWrap only stopped the TCP socket underneath. Records that were already received kept going through ClearOut() and were handed to JS anyway. I ran into this through the HTTP server. When a pipelined request comes in while a big response is still being sent, the server pauses the socket and the parser. Over TLS, the rest of the request was still pushed into the paused parser, which failed with HPE_PAUSED and the server dropped the connection. Plain HTTP was fine. With this change, ClearOut() stops after an emit if ReadStop() was called, and leaves the remaining records in enc_in_. ReadStart() then runs a cycle to deliver them, since the client may not send anything else that would trigger it. The cycle runs after the TCP socket is started again, because JS can pause and resume while handling the data, and starting the socket twice fails with EALREADY. Fixes: nodejs#67455 Signed-off-by: Barath <barathraj048@gmail.com>
Collaborator
|
Review requested:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #67676 +/- ##
==========================================
- Coverage 90.71% 90.60% -0.12%
==========================================
Files 801 801
Lines 280906 281062 +156
Branches 54249 54252 +3
==========================================
- Hits 254832 254663 -169
- Misses 16246 16576 +330
+ Partials 9828 9823 -5
🚀 New features to boost your workflow:
|
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.
When JS calls ReadStop() on a TLS socket, TLSWrap only stopped the TCP socket underneath. Records that were already received kept going through ClearOut() and were handed to JS anyway.
I ran into this through the HTTP server. When a pipelined request comes in while a big response is still being sent, the server pauses the socket and the parser. Over TLS, the rest of the request was still pushed into the paused parser, which failed with HPE_PAUSED and the server dropped the connection. Plain HTTP was fine.
With this change, ClearOut() stops after an emit if ReadStop() was called, and leaves the remaining records in enc_in_. ReadStart() then runs a cycle to deliver them, since the client may not send anything else that would trigger it. The cycle runs after the TCP socket is started again, because JS can pause and resume while handling the data, and starting the socket twice fails with EALREADY.
Fixes: #67455
Refs: connectrpc/connect-es#1884
Testing
Tested on Linux (Ubuntu 24.04 on WSL2, x64).
test-https-pipeline-paused-parser.jsfails without this change (clientErrorwithHPE_PAUSED) and passes with it.test-tls-*,test-https-*,test-http2-*(parallel and sequential): 644 passed.make test-only: 7628 passed. 6test-domain-*abort*tests timed out under load because of WSL's crash handler (/wsl-capture-crash). They pass when run alone and don't use TLS.Notes for reviewers
datalistener on the TLS socket, which unconsumes the parser. Users ofhttps.createServer()can still hit it without that workaround.