Skip to content

Commit

Permalink
stream: fix writableStream.abort()
Browse files Browse the repository at this point in the history
This includes:

- Fixing `writableStream.abort(reason)`. Passing the reason was missing.

- Leaving a TODO to remove the internal abortReason property of
  WritableStreamDefaultController.

Signed-off-by: Daeyeon Jeong daeyeon.dev@gmail.com
PR-URL: nodejs#44327
Refs: https://streams.spec.whatwg.org/#writable-stream-abort
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
  • Loading branch information
daeyeon authored and Fyko committed Sep 15, 2022
1 parent 1d590bf commit 17913b3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 4 additions & 1 deletion lib/internal/webstreams/writablestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,11 @@ function writableStreamAbort(stream, reason) {
if (state === 'closed' || state === 'errored')
return PromiseResolve();

// TODO(daeyeon): Remove `controller[kState].abortReason` and use
// `controller[kState].abortController.signal.reason` for the
// `WritableStreamDefaultController.prototype.abortReason` getter.
controller[kState].abortReason = reason;
controller[kState].abortController.abort();
controller[kState].abortController.abort(reason);

if (stream[kState].pendingAbortRequest.abort.promise !== undefined)
return stream[kState].pendingAbortRequest.abort.promise;
Expand Down
5 changes: 0 additions & 5 deletions test/wpt/status/streams.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,5 @@
},
"transferable/transfer-with-messageport.window.js": {
"skip": "Browser-specific test"
},
"writable-streams/aborting.any.js": {
"fail": {
"expected": ["WritableStreamDefaultController.signal"]
}
}
}

0 comments on commit 17913b3

Please sign in to comment.