Repository navigation
tls: stop emitting data after ReadStop() - #67676
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>
|
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 might be @nodejs/security @nodejs/crypto @nodejs/http |
|
Thanks for looking at this! I wasn't sure about semver either, so here's what actually changes, to make it easier to decide:
About memory: while reading is stopped, the TCP stream underneath is stopped too, so If the synchronous emit in Also, the failing FIPS job ( |
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.