stream: preserve push signal abort reason

Pass the stream-wide signal reason directly to writer.fail() so valid
non-Error abort reasons are not replaced with an AbortError.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: codex:gpt-5.6-sol
PR-URL: https://github.com/nodejs/node/pull/64798
Fixes: https://github.com/nodejs/node/issues/64797
Reviewed-By: Aviv Keller <me@aviv.sh>
This commit is contained in:
Trivikram Kamat authored and Antoine du Hamel committed 2026-08-05 11:15:12 +02:00
1 parent 63fbd59e64
commit 2632d606bb
2 files changed
+13 -4

No files matched your search

@@ -107,6 +107,16 @@ async function testAbortSignal() {
);
}
async function testAbortSignalReason() {
const reason = 'test reason';
const ac = new AbortController();
const { writer } = push({ signal: ac.signal });
ac.abort(reason);
await assert.rejects(writer.write('data'), (err) => err === reason);
}
async function testPreAbortedSignal() {
const { readable } = push({ signal: AbortSignal.abort() });
await assert.rejects(async () => {
@@ -172,6 +182,7 @@ Promise.all([
testWriterFail(),
testConsumerBreak(),
testAbortSignal(),
testAbortSignalReason(),
testPreAbortedSignal(),
testConsumerBreakWriteSyncReturnsFalse(),
testPushWithTransforms(),