Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

remove core isErrored and isReadable #3459

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions lib/core/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -674,8 +666,6 @@ module.exports = {
kEnumerableProperty,
nop,
isDisturbed,
isErrored,
isReadable,
toUSVString,
isUSVString,
isBlobLike,
Expand Down
2 changes: 1 addition & 1 deletion lib/web/fetch/body.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
8 changes: 4 additions & 4 deletions lib/web/fetch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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?
Expand All @@ -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?
Expand Down
Loading