aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/builtins/js/ReadableStreamInternals.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-12-02 20:15:50 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-12-02 20:15:50 -0800
commitd9f9fc975beb9d5d8fe83f6ed2a084c36846522b (patch)
tree65b9a71aaea04222bd7c7631f25c5f698c11c26c /src/bun.js/builtins/js/ReadableStreamInternals.js
parentbdbc0f23e7235b1b1c9e24d251613f3b477a8abd (diff)
downloadbun-d9f9fc975beb9d5d8fe83f6ed2a084c36846522b.tar.gz
bun-d9f9fc975beb9d5d8fe83f6ed2a084c36846522b.tar.zst
bun-d9f9fc975beb9d5d8fe83f6ed2a084c36846522b.zip
Propagate reason in AbortSignal and reuse in ReadableStream.pipeTo
Similar to https://github.com/WebKit/WebKit/pull/7013
Diffstat (limited to 'src/bun.js/builtins/js/ReadableStreamInternals.js')
-rw-r--r--src/bun.js/builtins/js/ReadableStreamInternals.js13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/bun.js/builtins/js/ReadableStreamInternals.js b/src/bun.js/builtins/js/ReadableStreamInternals.js
index 15042baa5..f317eeaec 100644
--- a/src/bun.js/builtins/js/ReadableStreamInternals.js
+++ b/src/bun.js/builtins/js/ReadableStreamInternals.js
@@ -304,14 +304,9 @@ function readableStreamPipeToWritableStream(
pipeState.pendingWritePromise = @Promise.@resolve();
if (signal !== @undefined) {
- const algorithm = () => {
+ const algorithm = (reason) => {
if (pipeState.finalized) return;
- const error = @makeDOMException(
- "AbortError",
- "abort pipeTo from signal"
- );
-
@pipeToShutdownWithAction(
pipeState,
() => {
@@ -320,7 +315,7 @@ function readableStreamPipeToWritableStream(
@getByIdDirectPrivate(pipeState.destination, "state") ===
"writable";
const promiseDestination = shouldAbortDestination
- ? @writableStreamAbort(pipeState.destination, error)
+ ? @writableStreamAbort(pipeState.destination, reason)
: @Promise.@resolve();
const shouldAbortSource =
@@ -328,7 +323,7 @@ function readableStreamPipeToWritableStream(
@getByIdDirectPrivate(pipeState.source, "state") ===
@streamReadable;
const promiseSource = shouldAbortSource
- ? @readableStreamCancel(pipeState.source, error)
+ ? @readableStreamCancel(pipeState.source, reason)
: @Promise.@resolve();
let promiseCapability = @newPromiseCapability(@Promise);
@@ -350,7 +345,7 @@ function readableStreamPipeToWritableStream(
promiseSource.@then(handleResolvedPromise, handleRejectedPromise);
return promiseCapability.@promise;
},
- error
+ reason
);
};
if (@whenSignalAborted(signal, algorithm))