Skip to content

Commit

Permalink
Integrate abort reasons
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nidhijaju authored Nov 19, 2021
1 parent 9007937 commit 95973b4
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2101,7 +2101,7 @@ The following abstract operations operate on {{ReadableStream}} instances at a h
1. Let |promise| be [=a new promise=].
1. If |signal| is not undefined,
1. Let |abortAlgorithm| be the following steps:
1. Let |error| be a new "{{AbortError}}" {{DOMException}}.
1. Let |error| be |signal|'s [=AbortSignal/abort reason=].
1. Let |actions| be an empty [=ordered set=].
1. If |preventAbort| is false, [=set/append=] the following action to |actions|:
1. If |dest|.[=WritableStream/[[state]]=] is "`writable`", return !
Expand All @@ -2113,8 +2113,7 @@ The following abstract operations operate on {{ReadableStream}} instances at a h
1. Otherwise, return [=a promise resolved with=] undefined.
1. [=Shutdown with an action=] consisting of [=getting a promise to wait for all=] of the actions
in |actions|, and with |error|.
1. If |signal|'s [=AbortSignal/aborted flag=] is set, perform |abortAlgorithm| and return
|promise|.
1. If |signal| is [=AbortSignal/aborted=], perform |abortAlgorithm| and return |promise|.
1. [=AbortSignal/Add=] |abortAlgorithm| to |signal|.
1. [=In parallel=] <span class="XXX">but not really; see <a
href="https://github.com/whatwg/streams/issues/905">#905</a></span>, using |reader| and
Expand Down Expand Up @@ -4518,7 +4517,8 @@ The following abstract operations operate on {{WritableStream}} instances at a h
1. If |stream|.[=WritableStream/[[state]]=] is "`closed`" or "`errored`", return
[=a promise resolved with=] undefined.
1. [=Signal abort=] on
|stream|.[=WritableStream/[[controller]]=].[=WritableStreamDefaultController/[[signal]]=].
|stream|.[=WritableStream/[[controller]]=].[=WritableStreamDefaultController/[[signal]]=] with
|reason|.
1. Let |state| be |stream|.[=WritableStream/[[state]]=].
1. If |state| is "`closed`" or "`errored`", return [=a promise resolved with=] undefined.
<p class="note">We re-check the state because [=signaling abort=] runs author code and that might
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function ReadableStreamPipeTo(source, dest, preventClose, preventAbort, preventC
let abortAlgorithm;
if (signal !== undefined) {
abortAlgorithm = () => {
const error = new DOMException('Aborted', 'AbortError');
const error = signal.reason;
const actions = [];
if (preventAbort === false) {
actions.push(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function WritableStreamAbort(stream, reason) {
if (stream._state === 'closed' || stream._state === 'errored') {
return promiseResolvedWith(undefined);
}
stream._controller._abortController.abort();
stream._controller._abortController.abort(reason);
const state = stream._state;
if (state === 'closed' || state === 'errored') {
return promiseResolvedWith(undefined);
Expand Down
2 changes: 1 addition & 1 deletion reference-implementation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"minimatch": "^3.0.4",
"opener": "^1.5.1",
"webidl2js": "^16.2.0",
"wpt-runner": "^3.2.1"
"wpt-runner": "^4.0.0"
}
}
2 changes: 1 addition & 1 deletion reference-implementation/web-platform-tests

0 comments on commit 95973b4

Please sign in to comment.