Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fixup
  • Loading branch information
ronag committed Jul 27, 2021
commit 1c18eb99f05fd1822166b28af89c6710593ed6a2
8 changes: 7 additions & 1 deletion lib/internal/webstreams/adapters.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function newWritableStreamFromStreamWritable(streamWritable) {
closed = undefined;
return;
}
controller.error(new ERR_STREAM_PREMATURE_CLOSE());
controller.error(new AbortError());
controller = undefined;
});

Expand Down Expand Up @@ -402,6 +402,12 @@ function newReadableStreamFromStreamReadable(streamReadable) {
streamReadable.pause();

const cleanup = finished(streamReadable, (error) => {
if (error?.code === 'ERR_STREAM_PREMATURE_CLOSE') {
const err = new AbortError();
err.cause = error;
error = err;
}

cleanup();
// This is a protection against non-standard, legacy streams
// that happen to emit an error event again after finished is called.
Expand Down