Skip to content

Commit 95973b4

Browse files
authored
Integrate abort reasons
Following on from whatwg/dom#1027, with introduces custom abort reasons, this uses the AbortSignal's abort reason in the ReadableStreamPipeTo function. It also updates WritableStreamAbort to use the reason to signal abort. Closes #1165. Part of whatwg/dom#1030.
1 parent 9007937 commit 95973b4

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

index.bs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,7 +2101,7 @@ The following abstract operations operate on {{ReadableStream}} instances at a h
21012101
1. Let |promise| be [=a new promise=].
21022102
1. If |signal| is not undefined,
21032103
1. Let |abortAlgorithm| be the following steps:
2104-
1. Let |error| be a new "{{AbortError}}" {{DOMException}}.
2104+
1. Let |error| be |signal|'s [=AbortSignal/abort reason=].
21052105
1. Let |actions| be an empty [=ordered set=].
21062106
1. If |preventAbort| is false, [=set/append=] the following action to |actions|:
21072107
1. If |dest|.[=WritableStream/[[state]]=] is "`writable`", return !
@@ -2113,8 +2113,7 @@ The following abstract operations operate on {{ReadableStream}} instances at a h
21132113
1. Otherwise, return [=a promise resolved with=] undefined.
21142114
1. [=Shutdown with an action=] consisting of [=getting a promise to wait for all=] of the actions
21152115
in |actions|, and with |error|.
2116-
1. If |signal|'s [=AbortSignal/aborted flag=] is set, perform |abortAlgorithm| and return
2117-
|promise|.
2116+
1. If |signal| is [=AbortSignal/aborted=], perform |abortAlgorithm| and return |promise|.
21182117
1. [=AbortSignal/Add=] |abortAlgorithm| to |signal|.
21192118
1. [=In parallel=] <span class="XXX">but not really; see <a
21202119
href="https://github.com/whatwg/streams/issues/905">#905</a></span>, using |reader| and
@@ -4518,7 +4517,8 @@ The following abstract operations operate on {{WritableStream}} instances at a h
45184517
1. If |stream|.[=WritableStream/[[state]]=] is "`closed`" or "`errored`", return
45194518
[=a promise resolved with=] undefined.
45204519
1. [=Signal abort=] on
4521-
|stream|.[=WritableStream/[[controller]]=].[=WritableStreamDefaultController/[[signal]]=].
4520+
|stream|.[=WritableStream/[[controller]]=].[=WritableStreamDefaultController/[[signal]]=] with
4521+
|reason|.
45224522
1. Let |state| be |stream|.[=WritableStream/[[state]]=].
45234523
1. If |state| is "`closed`" or "`errored`", return [=a promise resolved with=] undefined.
45244524
<p class="note">We re-check the state because [=signaling abort=] runs author code and that might

reference-implementation/lib/abstract-ops/readable-streams.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ function ReadableStreamPipeTo(source, dest, preventClose, preventAbort, preventC
146146
let abortAlgorithm;
147147
if (signal !== undefined) {
148148
abortAlgorithm = () => {
149-
const error = new DOMException('Aborted', 'AbortError');
149+
const error = signal.reason;
150150
const actions = [];
151151
if (preventAbort === false) {
152152
actions.push(() => {

reference-implementation/lib/abstract-ops/writable-streams.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function WritableStreamAbort(stream, reason) {
107107
if (stream._state === 'closed' || stream._state === 'errored') {
108108
return promiseResolvedWith(undefined);
109109
}
110-
stream._controller._abortController.abort();
110+
stream._controller._abortController.abort(reason);
111111
const state = stream._state;
112112
if (state === 'closed' || state === 'errored') {
113113
return promiseResolvedWith(undefined);

reference-implementation/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
"minimatch": "^3.0.4",
2020
"opener": "^1.5.1",
2121
"webidl2js": "^16.2.0",
22-
"wpt-runner": "^3.2.1"
22+
"wpt-runner": "^4.0.0"
2323
}
2424
}

0 commit comments

Comments
 (0)