mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
stream: fix setting abort reason in ReadableStream.pipeTo()
In 14.2 in the specification, `error` should be signal’s abort reason. The current behavior seems to assume that only an `AbortError` instance is given as signal’s abort reason. Refs: https://streams.spec.whatwg.org/#readable-stream-pipe-to Signed-off-by: Daeyeon Jeong daeyeon.dev@gmail.com PR-URL: https://github.com/nodejs/node/pull/44418 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
1 parent
5cefd02618
commit
2facf8b8e0
3 files changed
+33
-11
No files matched your search
@@ -28,6 +28,7 @@ const {
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
AbortError,
|
||||
codes: {
|
||||
ERR_ILLEGAL_CONSTRUCTOR,
|
||||
ERR_INVALID_ARG_VALUE,
|
||||
@@ -1303,8 +1304,14 @@ function readableStreamPipeTo(
|
||||
}
|
||||
|
||||
function abortAlgorithm() {
|
||||
// Cannot use the AbortError class here. It must be a DOMException
|
||||
const error = new DOMException('The operation was aborted', 'AbortError');
|
||||
let error;
|
||||
if (signal.reason instanceof AbortError) {
|
||||
// Cannot use the AbortError class here. It must be a DOMException.
|
||||
error = new DOMException(signal.reason.message, 'AbortError');
|
||||
} else {
|
||||
error = signal.reason;
|
||||
}
|
||||
|
||||
const actions = [];
|
||||
if (!preventAbort) {
|
||||
ArrayPrototypePush(
|
||||
|
||||
Reference in new issue
Block a user