Skip to content

Commit

Permalink
WritableStream: remove the abortReason property
Browse files Browse the repository at this point in the history
Part of #1165, which discusses moving it instead to the AbortSignal's reason property per whatwg/dom#1027.
  • Loading branch information
nidhijaju committed Oct 25, 2021
1 parent 641df4b commit 4b6b93c
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 25 deletions.
15 changes: 0 additions & 15 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -4288,7 +4288,6 @@ The Web IDL definition for the {{WritableStreamDefaultController}} class is give
<xmp class="idl">
[Exposed=(Window,Worker,Worklet)]
interface WritableStreamDefaultController {
readonly attribute any abortReason;
readonly attribute AbortSignal signal;
undefined error(optional any e);
};
Expand All @@ -4309,9 +4308,6 @@ the following table:
<td><dfn>\[[abortAlgorithm]]</dfn>
<td class="non-normative">A promise-returning algorithm, taking one argument (the abort reason),
which communicates a requested abort to the [=underlying sink=]
<tr>
<td><dfn>\[[abortReason]]</dfn>
<td class="non-normative">The argument given to [$WritableStreamAbort$], or undefined.
<tr>
<td><dfn>\[[closeAlgorithm]]</dfn>
<td class="non-normative">A promise-returning algorithm which communicates a requested close to
Expand Down Expand Up @@ -4371,13 +4367,6 @@ closed. It is only used internally, and is never exposed to web developers.
sink=].
</dl>

<div algorithm>
The <dfn id="ws-default-controller-abort-reason" attribute
for="WritableStreamDefaultController">abortReason</dfn> getter steps are:

1. Return [=this=].[=WritableStreamDefaultController/[[abortReason]]=].
</div>

<div algorithm>
The <dfn id="ws-default-controller-signal" attribute
for="WritableStreamDefaultController">signal</dfn> getter steps are:
Expand Down Expand Up @@ -4528,9 +4517,6 @@ 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. Set
|stream|.[=WritableStream/[[controller]]=].[=WritableStreamDefaultController/[[abortReason]]=]
to |reason|.
1. [=Signal abort=] on
|stream|.[=WritableStream/[[controller]]=].[=WritableStreamDefaultController/[[signal]]=].
1. Let |state| be |stream|.[=WritableStream/[[state]]=].
Expand Down Expand Up @@ -4960,7 +4946,6 @@ The following abstract operations support the implementation of the
1. Set |controller|.[=WritableStreamDefaultController/[[stream]]=] to |stream|.
1. Set |stream|.[=WritableStream/[[controller]]=] to |controller|.
1. Perform ! [$ResetQueue$](|controller|).
1. Set |controller|.[=WritableStreamDefaultController/[[abortReason]]=] to undefined.
1. Set |controller|.[=WritableStreamDefaultController/[[signal]]=] to a new {{AbortSignal}}.
1. Set |controller|.[=WritableStreamDefaultController/[[started]]=] to false.
1. Set |controller|.[=WritableStreamDefaultController/[[strategySizeAlgorithm]]=] to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ const { AbortSteps, ErrorSteps } = require('./abstract-ops/internal-methods.js')
const { ResetQueue } = require('./abstract-ops/queue-with-sizes.js');

exports.implementation = class WritableStreamDefaultControllerImpl {
get abortReason() {
return this._abortReason;
}
get signal() {
return this._abortController.signal;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[Exposed=(Window,Worker,Worklet)]
interface WritableStreamDefaultController {
readonly attribute any abortReason;
readonly attribute AbortSignal signal;
void error(optional any e);
};
2 changes: 0 additions & 2 deletions reference-implementation/lib/abstract-ops/writable-streams.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ function WritableStreamAbort(stream, reason) {
if (stream._state === 'closed' || stream._state === 'errored') {
return promiseResolvedWith(undefined);
}
stream._controller._abortReason = reason;
stream._controller._abortController.abort();
const state = stream._state;
if (state === 'closed' || state === 'errored') {
Expand Down Expand Up @@ -542,7 +541,6 @@ function SetUpWritableStreamDefaultController(stream, controller, startAlgorithm
controller._queueTotalSize = undefined;
ResetQueue(controller);

controller._abortReason = undefined;
controller._abortController = new AbortController();
controller._started = false;

Expand Down
2 changes: 1 addition & 1 deletion reference-implementation/web-platform-tests
7 changes: 4 additions & 3 deletions writable-stream-abort-signal-explainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ streams such as [WebTransport](https://w3c.github.io/webtransport/).
On [WritableStreamDefaultController](https://streams.spec.whatwg.org/#writablestreamdefaultcontroller)
(the controller argument that is passed to underlying sinks):

* [`abortReason`](https://streams.spec.whatwg.org/#writablestreamdefaultcontroller-abortreason): The argument passed
to `writable.abort()` or `writer.abort()`. Undefined if no argument was passed or `abort()` hasn't been called.
* [`signal`](https://streams.spec.whatwg.org/#writablestreamdefaultcontroller-signal): An AbortSignal. By using
`signal.addEventListener('abort', …)` an underlying sink can abort the pending write or close operation when the
stream is aborted.
Expand All @@ -44,7 +42,7 @@ const ws = new WritableStream({
return new Promise((resolve, reject) => {
setTimeout(resolve, 1000);
controller.signal.addEventListener('abort',
() => reject(controller.abortReason));
() => reject(controller.signal.reason));
});
}
});
Expand Down Expand Up @@ -117,3 +115,6 @@ would be unclear and confusing.
* It was initially proposed that an `AbortSignal` could be passed to each sink `write()` call. However, since the
abort signal does not need to change between two `write()` calls, it was thought better to just add a `signal` property
on `WritableStreamDefaultController`.
* Previously, [WritableStreamDefaultController](https://streams.spec.whatwg.org/#writablestreamdefaultcontroller) had
an `abortReason` property that was an argument given to
[WritableStreamAbort](https://streams.spec.whatwg.org/#writable-stream-abort). However, after some discussion, it was thought better to just add the `reason` property to the `AbortSignal`.

0 comments on commit 4b6b93c

Please sign in to comment.