mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
stream: refactor to use validateAbortSignal
PR-URL: https://github.com/nodejs/node/pull/46520 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
d8c527f24f
commit
f91260b32a
2 files changed
+13
-15
No files matched your search
@@ -394,7 +394,6 @@ ObjectDefineProperty(AbortController.prototype, SymbolToStringTag, {
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
kAborted,
|
||||
AbortController,
|
||||
AbortSignal,
|
||||
ClonedAbortSignal,
|
||||
|
||||
@@ -58,14 +58,11 @@ const {
|
||||
} = require('internal/util');
|
||||
|
||||
const {
|
||||
validateAbortSignal,
|
||||
validateBuffer,
|
||||
validateObject,
|
||||
} = require('internal/validators');
|
||||
|
||||
const {
|
||||
kAborted,
|
||||
} = require('internal/abort_controller');
|
||||
|
||||
const {
|
||||
MessageChannel,
|
||||
} = require('internal/worker/io');
|
||||
@@ -381,8 +378,9 @@ class ReadableStream {
|
||||
const preventClose = options?.preventClose;
|
||||
const signal = options?.signal;
|
||||
|
||||
if (signal !== undefined && signal?.[kAborted] === undefined)
|
||||
throw new ERR_INVALID_ARG_TYPE('options.signal', 'AbortSignal', signal);
|
||||
if (signal !== undefined) {
|
||||
validateAbortSignal(signal, 'options.signal');
|
||||
}
|
||||
|
||||
if (isReadableStreamLocked(this))
|
||||
throw new ERR_INVALID_STATE.TypeError('The ReadableStream is locked');
|
||||
@@ -422,8 +420,9 @@ class ReadableStream {
|
||||
const preventClose = options?.preventClose;
|
||||
const signal = options?.signal;
|
||||
|
||||
if (signal !== undefined && signal?.[kAborted] === undefined)
|
||||
throw new ERR_INVALID_ARG_TYPE('options.signal', 'AbortSignal', signal);
|
||||
if (signal !== undefined) {
|
||||
validateAbortSignal(signal, 'options.signal');
|
||||
}
|
||||
|
||||
if (isReadableStreamLocked(this))
|
||||
throw new ERR_INVALID_STATE.TypeError('The ReadableStream is locked');
|
||||
@@ -1269,12 +1268,12 @@ function readableStreamPipeTo(
|
||||
|
||||
let shuttingDown = false;
|
||||
|
||||
if (signal !== undefined && signal?.[kAborted] === undefined) {
|
||||
return PromiseReject(
|
||||
new ERR_INVALID_ARG_TYPE(
|
||||
'options.signal',
|
||||
'AbortSignal',
|
||||
signal));
|
||||
if (signal !== undefined) {
|
||||
try {
|
||||
validateAbortSignal(signal, 'options.signal');
|
||||
} catch (error) {
|
||||
return PromiseReject(error);
|
||||
}
|
||||
}
|
||||
|
||||
const promise = createDeferredPromise();
|
||||
|
||||
Reference in new issue
Block a user