Release the endpoints of a native TypeScript streams pipe #8056
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.37) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 228 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.325
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #8056"
general
weight: 0.35
ryanking13
Under typescript_implemented_streams, pipeTo() from a native-backed readable (a fetch() or service-binding body, a buffer-backed body, Blob.stream(), a socket's readable) into a native-backed writable (a connect() socket's writable, a writable received over JS RPC) runs at the C++ layer through the sink's pipeFrom hook. Extracting the two native halves locks both streams with internal handles, which the fast path never released: once the pipe settled, both endpoints stayed locked for good, so the writable could not be closed, aborted or written again, and the source could not be read or cancelled. The JS pipe path, and the C++ implementation, release both.
Once pipeFrom settles, the fast path now finishes the pipe as the JS pipe's shutdown and finalize would: it closes the destination through its internal writer when the pipe succeeded, or aborts it with the pipe's error, and then releases the writer and the source's reader. The extracted sink's hooks no longer reach the C++ sink, so neither reaches the connection.
The source has been closed since its extraction and stays closed, so it reads done whatever the outcome. On an abort that is the spec's cancel. C++ instead errors the source when the pipe is aborted or the source fails, and with an already-aborted signal touches neither endpoint. The sockets suite pins these as a divergence.
Tests: nativePipeReleasesEndpoints in the sockets suite (success, mid-pipe abort, an already-aborted signal, a failing service-binding body), and the cross-implementation RPC test for a writable received over RPC, with and without a write made before the pipe, and with a failing source.
typescript_implemented_streams is still experimental, with no enable date, so the change needs no compatibility flag.
Fixes: https://github.com/cloudflare/workerd/issues/8049