{{ message }}
Repository navigation
Conversation
A TransformStream write that parks on backpressure was resumed from the read that lifted the backpressure, so transform(), the writes queued behind it, and flush() ran in the reader's async context instead of the writer's. Capture the async context frame when the write parks and restore it while the continuation runs, matching the context the spec's [[backpressureChangePromise]] reaction had. Fixes: nodejs#66906 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGUJ9PwPYkYJiCpUEsr7KJ Signed-off-by: Matteo Collina <hello@matteocollina.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 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.

A
TransformStreamwrite that parks on backpressure is resumed by the read that lifts the backpressure (transformStreamSetBackpressure(stream, false)enqueueswriteContinuation). Since #65143/#65625 that meanttransform()for the parked chunk, every write queued behind it (the continuation now attaches the writable controller'swriteFulfilled/writeRejected), and finallyflush()ran in the reader's async context instead of the writer's.This captures the
AsyncContextFramewhen the write parks and restores it while the continuation runs, so the perform-transform call and the write reactions are registered in the same context the spec's[[backpressureChangePromise]]reaction had. The continuation still runs at the same microtask position.Issue repro, before/after:
The reverse direction was also broken (not reported in the issue): with the pipe started outside any store and the reader inside
als.run('reader'),transform()/flush()sawreader. The new test covers both.benchmark/webstreams/pipe-through.js(10 runs) shows no significant change (default+0.33% ±4.16%,transform-2.43% ±2.89%).Backport note: v24.x and v26.x still have the async_hooks-based
AsyncLocalStorage(--no-async-context-frame, removed on main in #63641), where the issue also reproduces. Backports need an extra fallback for that mode, e.g. reverting to promise-based parking when async hooks are enabled.Fixes: #66906
🤖 Generated with Claude Code
https://claude.ai/code/session_01LGUJ9PwPYkYJiCpUEsr7KJ