Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fixup error propagation in Web streams to Node.js streams adapters #2593

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions src/node/internal/streams_adapters.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export function newWritableStreamFromStreamWritable(streamWritable) {
},

abort(reason) {
destroy(streamWritable, reason);
destroy.call(streamWritable, reason);
},

close() {
Expand Down Expand Up @@ -223,7 +223,7 @@ export function newStreamWritableFromWritableStream(
// thrown we don't want those to cause an unhandled
// rejection. Let's just escape the promise and
// handle it separately.
process.nextTick(() => destroy(writable, error));
process.nextTick(() => destroy.call(writable, error));
}
}

Expand Down Expand Up @@ -255,7 +255,7 @@ export function newStreamWritableFromWritableStream(
try {
callback(error);
} catch (error) {
destroy(writable, error);
destroy.call(writable, error);
}
}

Expand Down Expand Up @@ -302,7 +302,7 @@ export function newStreamWritableFromWritableStream(
// thrown we don't want those to cause an unhandled
// rejection. Let's just escape the promise and
// handle it separately.
process.nextTick(() => destroy(writable, error));
process.nextTick(() => destroy.call(writable, error));
}
}

Expand All @@ -318,13 +318,13 @@ export function newStreamWritableFromWritableStream(
// ended, we signal an error on the stream.Writable.
closed = true;
if (!isWritableEnded(writable))
destroy(writable, new ERR_STREAM_PREMATURE_CLOSE());
destroy.call(writable, new ERR_STREAM_PREMATURE_CLOSE());
},
(error) => {
// If the WritableStream errors before the stream.Writable has been
// destroyed, signal an error on the stream.Writable.
closed = true;
destroy(writable, error);
destroy.call(writable, error);
}
);

Expand Down Expand Up @@ -421,7 +421,7 @@ export function newReadableStreamFromStreamReadable(
},

cancel(reason) {
destroy(streamReadable, reason);
destroy.call(streamReadable, reason);
},
},
strategy
Expand Down Expand Up @@ -476,7 +476,9 @@ export function newStreamReadableFromReadableStream(
readable.push(chunk.value);
}
},
(error) => destroy(readable, error)
(error) => {
destroy.call(readable, error);
}
);
},

Expand Down Expand Up @@ -510,7 +512,7 @@ export function newStreamReadableFromReadableStream(
},
(error) => {
closed = true;
destroy(readable, error);
destroy.call(readable, error);
}
);

Expand Down Expand Up @@ -636,7 +638,7 @@ export function newStreamDuplexFromReadableWritablePair(
// thrown we don't want those to cause an unhandled
// rejection. Let's just escape the promise and
// handle it separately.
process.nextTick(() => destroy(duplex, error));
process.nextTick(() => destroy.call(duplex, error));
}
}

Expand Down Expand Up @@ -669,7 +671,7 @@ export function newStreamDuplexFromReadableWritablePair(
try {
callback(error);
} catch (error) {
destroy(duplex, error);
destroy.call(duplex, error);
}
}

Expand All @@ -688,7 +690,7 @@ export function newStreamDuplexFromReadableWritablePair(
// thrown we don't want those to cause an unhandled
// rejection. Let's just escape the promise and
// handle it separately.
process.nextTick(() => destroy(duplex, error));
process.nextTick(() => destroy.call(duplex, error));
}
}

Expand All @@ -706,7 +708,7 @@ export function newStreamDuplexFromReadableWritablePair(
duplex.push(chunk.value);
}
},
(error) => destroy(duplex, error)
(error) => destroy.call(duplex, error)
);
},

Expand Down Expand Up @@ -747,12 +749,12 @@ export function newStreamDuplexFromReadableWritablePair(
() => {
writableClosed = true;
if (!isWritableEnded(duplex))
destroy(duplex, new ERR_STREAM_PREMATURE_CLOSE());
destroy.call(duplex, new ERR_STREAM_PREMATURE_CLOSE());
},
(error) => {
writableClosed = true;
readableClosed = true;
destroy(duplex, error);
destroy.call(duplex, error);
}
);

Expand All @@ -763,7 +765,7 @@ export function newStreamDuplexFromReadableWritablePair(
(error) => {
writableClosed = true;
readableClosed = true;
destroy(duplex, error);
destroy.call(duplex, error);
}
);

Expand Down
Loading
Loading