diff --git a/lib/core/util.js b/lib/core/util.js index 9b566ef2962..8fc81dbd47c 100644 --- a/lib/core/util.js +++ b/lib/core/util.js @@ -443,14 +443,6 @@ function isDisturbed (body) { return !!(body && (stream.isDisturbed(body) || body[kBodyUsed])) } -function isErrored (body) { - return !!(body && stream.isErrored(body)) -} - -function isReadable (body) { - return !!(body && stream.isReadable(body)) -} - function getSocketInfo (socket) { return { localAddress: socket.localAddress, @@ -674,8 +666,6 @@ module.exports = { kEnumerableProperty, nop, isDisturbed, - isErrored, - isReadable, toUSVString, isUSVString, isBlobLike, diff --git a/lib/web/fetch/body.js b/lib/web/fetch/body.js index 55718ac7c81..e5642dec70d 100644 --- a/lib/web/fetch/body.js +++ b/lib/web/fetch/body.js @@ -16,7 +16,7 @@ const { kState } = require('./symbols') const { webidl } = require('./webidl') const { Blob } = require('node:buffer') const assert = require('node:assert') -const { isErrored } = require('../../core/util') +const { isErrored } = require('node:stream') const { isArrayBuffer } = require('node:util/types') const { serializeAMimeType } = require('./data-url') const { multipartFormDataParser } = require('./formdata-parser') diff --git a/lib/web/fetch/index.js b/lib/web/fetch/index.js index 406ed7f31cb..efc0334f74f 100644 --- a/lib/web/fetch/index.js +++ b/lib/web/fetch/index.js @@ -58,8 +58,8 @@ const { subresourceSet } = require('./constants') const EE = require('node:events') -const { Readable, pipeline, finished } = require('node:stream') -const { addAbortListener, isErrored, isReadable, bufferToLowerCasedHeaderName } = require('../../core/util') +const { Readable, pipeline, finished, isErrored, isReadable } = require('node:stream') +const { addAbortListener, bufferToLowerCasedHeaderName } = require('../../core/util') const { dataURLProcessor, serializeAMimeType, minimizeSupportedMimeType } = require('./data-url') const { getGlobalDispatcher } = require('../../global') const { webidl } = require('./webidl') @@ -327,7 +327,7 @@ function abortFetch (p, request, responseObject, error) { // 2. If request’s body is not null and is readable, then cancel request’s // body with error. - if (request.body != null && isReadable(request.body?.stream)) { + if (request.body?.stream != null && isReadable(request.body.stream)) { request.body.stream.cancel(error).catch((err) => { if (err.code === 'ERR_INVALID_STATE') { // Node bug? @@ -347,7 +347,7 @@ function abortFetch (p, request, responseObject, error) { // 5. If response’s body is not null and is readable, then error response’s // body with error. - if (response.body != null && isReadable(response.body?.stream)) { + if (response.body?.stream != null && isReadable(response.body.stream)) { response.body.stream.cancel(error).catch((err) => { if (err.code === 'ERR_INVALID_STATE') { // Node bug?