From 683f91ae2c793409ac20c5ade6541f6b4323f9ed Mon Sep 17 00:00:00 2001 From: Khafra Date: Fri, 1 Dec 2023 15:36:22 -0500 Subject: [PATCH 1/3] remove require('stream/web') --- benchmarks/benchmark-http2.js | 1 - benchmarks/benchmark-https.js | 1 - benchmarks/benchmark.js | 1 - lib/core/util.js | 20 +++++--------------- lib/fetch/body.js | 11 ----------- lib/fetch/index.js | 6 ------ lib/fetch/request.js | 6 ------ lib/fetch/response.js | 1 - lib/fetch/util.js | 7 ------- test/fetch/client-fetch.js | 1 - test/fetch/response.js | 1 - test/mock-agent.js | 2 -- test/node-fetch/main.js | 1 - test/utils/stream.js | 3 --- 14 files changed, 5 insertions(+), 57 deletions(-) diff --git a/benchmarks/benchmark-http2.js b/benchmarks/benchmark-http2.js index d8555de22b5..af7b3cdbd86 100644 --- a/benchmarks/benchmark-http2.js +++ b/benchmarks/benchmark-http2.js @@ -7,7 +7,6 @@ const path = require('path') const { readFileSync } = require('fs') const { table } = require('table') const { Writable } = require('stream') -const { WritableStream } = require('stream/web') const { isMainThread } = require('worker_threads') const { Pool, Client, fetch, Agent, setGlobalDispatcher } = require('..') diff --git a/benchmarks/benchmark-https.js b/benchmarks/benchmark-https.js index a364f0a0c43..b42b01d0329 100644 --- a/benchmarks/benchmark-https.js +++ b/benchmarks/benchmark-https.js @@ -6,7 +6,6 @@ const path = require('path') const { readFileSync } = require('fs') const { table } = require('table') const { Writable } = require('stream') -const { WritableStream } = require('stream/web') const { isMainThread } = require('worker_threads') const { Pool, Client, fetch, Agent, setGlobalDispatcher } = require('..') diff --git a/benchmarks/benchmark.js b/benchmarks/benchmark.js index 5bf3d2ede4f..95e301771c7 100644 --- a/benchmarks/benchmark.js +++ b/benchmarks/benchmark.js @@ -5,7 +5,6 @@ const os = require('os') const path = require('path') const { table } = require('table') const { Writable } = require('stream') -const { WritableStream } = require('stream/web') const { isMainThread } = require('worker_threads') const { Pool, Client, fetch, Agent, setGlobalDispatcher } = require('..') diff --git a/lib/core/util.js b/lib/core/util.js index c9524b32a80..82cf3260b9f 100644 --- a/lib/core/util.js +++ b/lib/core/util.js @@ -359,22 +359,9 @@ function getSocketInfo (socket) { } } -async function * convertIterableToBuffer (iterable) { - for await (const chunk of iterable) { - yield Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk) - } -} - /** @type {globalThis['ReadableStream']} */ -let ReadableStream function ReadableStreamFrom (iterable) { - if (!ReadableStream) { - ReadableStream = require('stream/web').ReadableStream - } - - if (ReadableStream.from) { - return ReadableStream.from(convertIterableToBuffer(iterable)) - } + // We cannot use ReadableStream.from here because it does not return a byte stream. let iterator return new ReadableStream( @@ -387,10 +374,13 @@ function ReadableStreamFrom (iterable) { if (done) { queueMicrotask(() => { controller.close() + controller.byobRequest?.respond(0) }) } else { const buf = Buffer.isBuffer(value) ? value : Buffer.from(value) - controller.enqueue(new Uint8Array(buf)) + if (buf.byteLength) { + controller.enqueue(new Uint8Array(buf)) + } } return controller.desiredSize > 0 }, diff --git a/lib/fetch/body.js b/lib/fetch/body.js index 58da2941a85..cf7f07996de 100644 --- a/lib/fetch/body.js +++ b/lib/fetch/body.js @@ -22,8 +22,6 @@ const { isUint8Array, isArrayBuffer } = require('util/types') const { File: UndiciFile } = require('./file') const { parseMIMEType, serializeAMimeType } = require('./dataURL') -let ReadableStream = globalThis.ReadableStream - /** @type {globalThis['File']} */ const File = NativeFile ?? UndiciFile const textEncoder = new TextEncoder() @@ -31,10 +29,6 @@ const textDecoder = new TextDecoder() // https://fetch.spec.whatwg.org/#concept-bodyinit-extract function extractBody (object, keepalive = false) { - if (!ReadableStream) { - ReadableStream = require('stream/web').ReadableStream - } - // 1. Let stream be null. let stream = null @@ -258,11 +252,6 @@ function extractBody (object, keepalive = false) { // https://fetch.spec.whatwg.org/#bodyinit-safely-extract function safelyExtractBody (object, keepalive = false) { - if (!ReadableStream) { - // istanbul ignore next - ReadableStream = require('stream/web').ReadableStream - } - // To safely extract a body and a `Content-Type` value from // a byte sequence or BodyInit object object, run these steps: diff --git a/lib/fetch/index.js b/lib/fetch/index.js index 8495ecabde8..7c006350b1c 100644 --- a/lib/fetch/index.js +++ b/lib/fetch/index.js @@ -60,7 +60,6 @@ const EE = require('events') const { Readable, pipeline } = require('stream') const { addAbortListener, isErrored, isReadable, nodeMajor, nodeMinor } = require('../core/util') const { dataURLProcessor, serializeAMimeType, parseMIMEType } = require('./dataURL') -const { TransformStream } = require('stream/web') const { getGlobalDispatcher } = require('../global') const { webidl } = require('./webidl') const { STATUS_CODES } = require('http') @@ -68,7 +67,6 @@ const GET_OR_HEAD = ['GET', 'HEAD'] /** @type {import('buffer').resolveObjectURL} */ let resolveObjectURL -let ReadableStream = globalThis.ReadableStream class Fetch extends EE { constructor (dispatcher) { @@ -1934,10 +1932,6 @@ async function httpNetworkFetch ( // 15. Let stream be a new ReadableStream. // 16. Set up stream with byte reading support with pullAlgorithm set to pullAlgorithm, // cancelAlgorithm set to cancelAlgorithm. - if (!ReadableStream) { - ReadableStream = require('stream/web').ReadableStream - } - const stream = new ReadableStream( { async start (controller) { diff --git a/lib/fetch/request.js b/lib/fetch/request.js index 6fe4dff64c4..85b8bb0df2f 100644 --- a/lib/fetch/request.js +++ b/lib/fetch/request.js @@ -32,8 +32,6 @@ const { kHeadersList, kConstruct } = require('../core/symbols') const assert = require('assert') const { getMaxListeners, setMaxListeners, getEventListeners, defaultMaxListeners } = require('events') -let TransformStream = globalThis.TransformStream - const kAbortController = Symbol('abortController') const requestFinalizer = new FinalizationRegistry(({ signal, abort }) => { @@ -516,10 +514,6 @@ class Request { } // 2. Set finalBody to the result of creating a proxy for inputBody. - if (!TransformStream) { - TransformStream = require('stream/web').TransformStream - } - // https://streams.spec.whatwg.org/#readablestream-create-a-proxy const identityTransform = new TransformStream() inputBody.stream.pipeThrough(identityTransform) diff --git a/lib/fetch/response.js b/lib/fetch/response.js index c97951065be..af4f34a2f3b 100644 --- a/lib/fetch/response.js +++ b/lib/fetch/response.js @@ -27,7 +27,6 @@ const { kHeadersList, kConstruct } = require('../core/symbols') const assert = require('assert') const { types } = require('util') -const ReadableStream = globalThis.ReadableStream || require('stream/web').ReadableStream const textEncoder = new TextEncoder('utf-8') // https://fetch.spec.whatwg.org/#response-class diff --git a/lib/fetch/util.js b/lib/fetch/util.js index e0426be3bcd..c1b26d0b511 100644 --- a/lib/fetch/util.js +++ b/lib/fetch/util.js @@ -890,14 +890,7 @@ async function fullyReadBody (body, processBody, processBodyError) { } } -/** @type {ReadableStream} */ -let ReadableStream = globalThis.ReadableStream - function isReadableStreamLike (stream) { - if (!ReadableStream) { - ReadableStream = require('stream/web').ReadableStream - } - return stream instanceof ReadableStream || ( stream[Symbol.toStringTag] === 'ReadableStream' && typeof stream.tee === 'function' diff --git a/test/fetch/client-fetch.js b/test/fetch/client-fetch.js index 9009d547ec6..4046785f795 100644 --- a/test/fetch/client-fetch.js +++ b/test/fetch/client-fetch.js @@ -4,7 +4,6 @@ const { test, teardown } = require('tap') const { createServer } = require('http') -const { ReadableStream } = require('stream/web') const { Blob } = require('buffer') const { fetch, Response, Request, FormData, File } = require('../..') const { Client, setGlobalDispatcher, Agent } = require('../..') diff --git a/test/fetch/response.js b/test/fetch/response.js index 422c7ef2e02..066adb1e7b3 100644 --- a/test/fetch/response.js +++ b/test/fetch/response.js @@ -4,7 +4,6 @@ const { test } = require('tap') const { Response } = require('../../') -const { ReadableStream } = require('stream/web') const { Blob: ThirdPartyBlob, FormData: ThirdPartyFormData diff --git a/test/mock-agent.js b/test/mock-agent.js index c9ffda443aa..920605797d3 100644 --- a/test/mock-agent.js +++ b/test/mock-agent.js @@ -2497,7 +2497,6 @@ test('MockAgent - headers in mock dispatcher intercept should be case-insensitiv // https://github.com/nodejs/undici/issues/1757 test('MockAgent - reply callback can be asynchronous', { skip: nodeMajor < 16 }, async (t) => { const { fetch } = require('..') - const ReadableStream = globalThis.ReadableStream || require('stream/web').ReadableStream class MiniflareDispatcher extends Dispatcher { constructor (inner, options) { @@ -2605,7 +2604,6 @@ test('MockAgent - headers should be array of strings', async (t) => { test('MockAgent - Sending ReadableStream body', { skip: nodeMajor < 16 }, async (t) => { t.plan(1) const { fetch } = require('..') - const ReadableStream = globalThis.ReadableStream || require('stream/web').ReadableStream const mockAgent = new MockAgent() setGlobalDispatcher(mockAgent) diff --git a/test/node-fetch/main.js b/test/node-fetch/main.js index 358a969b574..d702a2743fc 100644 --- a/test/node-fetch/main.js +++ b/test/node-fetch/main.js @@ -27,7 +27,6 @@ const RequestOrig = require('../../lib/fetch/request.js').Request const ResponseOrig = require('../../lib/fetch/response.js').Response const TestServer = require('./utils/server.js') const chaiTimeout = require('./utils/chai-timeout.js') -const { ReadableStream } = require('stream/web') function isNodeLowerThan (version) { return !~process.version.localeCompare(version, undefined, { numeric: true }) diff --git a/test/utils/stream.js b/test/utils/stream.js index b78ff5c5538..e35ca29fe44 100644 --- a/test/utils/stream.js +++ b/test/utils/stream.js @@ -2,8 +2,6 @@ const { Readable, Writable } = require('stream') -let ReadableStream - function createReadable (data) { return new Readable({ read () { @@ -41,7 +39,6 @@ class Source { } function createReadableStream (data) { - ReadableStream = require('stream/web').ReadableStream return new ReadableStream(new Source(data)) } From bc6672aec5e5a2299fabbab614793f0022804220 Mon Sep 17 00:00:00 2001 From: Khafra Date: Fri, 1 Dec 2023 15:49:04 -0500 Subject: [PATCH 2/3] remove node <= 16 version checks --- test/client-pipeline.js | 8 +-- test/client-request.js | 31 ++------- test/esm-wrapper.js | 27 ++++---- test/fetch/abort.js | 3 +- test/fetch/bundle.js | 8 +-- test/fetch/client-node-max-header-size.js | 8 +-- test/fetch/issue-1447.js | 8 +-- test/fetch/resource-timing.js | 2 +- test/fetch/user-agent.js | 8 +-- test/issue-1903.js | 78 ----------------------- test/issue-2065.js | 8 +-- test/issue-2078.js | 8 +-- test/issue-2349.js | 8 +-- test/jest/instanceof-error.test.js | 7 +- test/jest/issue-1757.test.js | 5 +- test/jest/mock-scope.test.js | 5 +- test/mock-agent.js | 21 ++---- test/mock-pool.js | 6 +- test/mock-utils.js | 15 ++--- test/proxy-agent.js | 5 +- test/redirect-request.js | 3 +- test/request-timeout.js | 3 +- test/tls-client-cert.js | 70 -------------------- test/tls-session-reuse.js | 9 +-- test/util.js | 2 +- 25 files changed, 52 insertions(+), 304 deletions(-) delete mode 100644 test/issue-1903.js delete mode 100644 test/tls-client-cert.js diff --git a/test/client-pipeline.js b/test/client-pipeline.js index 9b677a02774..75b59e83422 100644 --- a/test/client-pipeline.js +++ b/test/client-pipeline.js @@ -11,7 +11,6 @@ const { Writable, PassThrough } = require('stream') -const { nodeMajor } = require('../lib/core/util') test('pipeline get', (t) => { t.plan(17) @@ -535,12 +534,7 @@ test('pipeline abort piped res', (t) => { return pipeline(body, pt, () => {}) }) .on('error', (err) => { - // Node < 13 doesn't always detect premature close. - if (nodeMajor < 13) { - t.ok(err) - } else { - t.equal(err.code, 'UND_ERR_ABORTED') - } + t.equal(err.code, 'UND_ERR_ABORTED') }) .end() }) diff --git a/test/client-request.js b/test/client-request.js index 3e6670523b8..3f74ce8cc70 100644 --- a/test/client-request.js +++ b/test/client-request.js @@ -11,7 +11,6 @@ const { Readable } = require('stream') const net = require('net') const { promisify } = require('util') const { NotSupportedError } = require('../lib/core/errors') -const { nodeMajor } = require('../lib/core/util') const { parseFormDataString } = require('./utils/formdata') test('request dump', (t) => { @@ -387,7 +386,7 @@ test('request long multibyte text', (t) => { }) }) -test('request blob', { skip: nodeMajor < 16 }, (t) => { +test('request blob', (t) => { t.plan(2) const obj = { asd: true } @@ -436,7 +435,7 @@ test('request arrayBuffer', (t) => { }) }) -test('request body', { skip: nodeMajor < 16 }, (t) => { +test('request body', (t) => { t.plan(1) const obj = { asd: true } @@ -462,7 +461,7 @@ test('request body', { skip: nodeMajor < 16 }, (t) => { }) }) -test('request post body no missing data', { skip: nodeMajor < 16 }, (t) => { +test('request post body no missing data', (t) => { t.plan(2) const server = createServer(async (req, res) => { @@ -495,7 +494,7 @@ test('request post body no missing data', { skip: nodeMajor < 16 }, (t) => { }) }) -test('request post body no extra data handler', { skip: nodeMajor < 16 }, (t) => { +test('request post body no extra data handler', (t) => { t.plan(3) const server = createServer(async (req, res) => { @@ -663,7 +662,7 @@ test('request raw responseHeaders', async (t) => { t.pass() }) -test('request formData', { skip: nodeMajor < 16 }, (t) => { +test('request formData', (t) => { t.plan(1) const obj = { asd: true } @@ -718,7 +717,7 @@ test('request text2', (t) => { }) }) -test('request with FormData body', { skip: nodeMajor < 16 }, (t) => { +test('request with FormData body', (t) => { const { FormData } = require('../') const { Blob } = require('buffer') @@ -769,24 +768,6 @@ test('request with FormData body', { skip: nodeMajor < 16 }, (t) => { }) }) -test('request with FormData body on node < 16', { skip: nodeMajor >= 16 }, async (t) => { - t.plan(1) - - // a FormData polyfill, for example - class FormData {} - - const fd = new FormData() - - const client = new Client('http://localhost:3000') - t.teardown(client.destroy.bind(client)) - - await t.rejects(client.request({ - path: '/', - method: 'POST', - body: fd - }), errors.InvalidArgumentError) -}) - test('request post body Buffer from string', (t) => { t.plan(2) const requestBody = Buffer.from('abcdefghijklmnopqrstuvwxyz') diff --git a/test/esm-wrapper.js b/test/esm-wrapper.js index a593fbdb531..8adb3278719 100644 --- a/test/esm-wrapper.js +++ b/test/esm-wrapper.js @@ -1,19 +1,14 @@ 'use strict' -const { nodeMajor, nodeMinor } = require('../lib/core/util') -if (!((nodeMajor > 14 || (nodeMajor === 14 && nodeMajor > 13)) || (nodeMajor === 12 && nodeMinor > 20))) { - require('tap') // shows skipped -} else { - ;(async () => { - try { - await import('./utils/esm-wrapper.mjs') - } catch (e) { - if (e.message === 'Not supported') { - require('tap') // shows skipped - return - } - console.error(e.stack) - process.exitCode = 1 +;(async () => { + try { + await import('./utils/esm-wrapper.mjs') + } catch (e) { + if (e.message === 'Not supported') { + require('tap') // shows skipped + return } - })() -} + console.error(e.stack) + process.exitCode = 1 + } +})() diff --git a/test/fetch/abort.js b/test/fetch/abort.js index e1ca1ebf9ea..95b51a0f827 100644 --- a/test/fetch/abort.js +++ b/test/fetch/abort.js @@ -5,7 +5,6 @@ const { fetch } = require('../..') const { createServer } = require('http') const { once } = require('events') const { DOMException } = require('../../lib/fetch/constants') -const { nodeMajor } = require('../../lib/core/util') const { AbortController: NPMAbortController } = require('abort-controller') @@ -37,7 +36,7 @@ test('Allow the usage of custom implementation of AbortController', async (t) => } }) -test('allows aborting with custom errors', { skip: nodeMajor === 16 }, async (t) => { +test('allows aborting with custom errors', async (t) => { const server = createServer().listen(0) t.teardown(server.close.bind(server)) diff --git a/test/fetch/bundle.js b/test/fetch/bundle.js index aa1257a49b4..93e605bf357 100644 --- a/test/fetch/bundle.js +++ b/test/fetch/bundle.js @@ -1,12 +1,6 @@ 'use strict' -const { test, skip } = require('tap') -const { nodeMajor } = require('../../lib/core/util') - -if (nodeMajor === 16) { - skip('esbuild uses static blocks with --keep-names which node 16.8 does not have') - process.exit() -} +const { test } = require('tap') const { Response, Request, FormData, Headers } = require('../../undici-fetch') diff --git a/test/fetch/client-node-max-header-size.js b/test/fetch/client-node-max-header-size.js index 737bae8ed6e..432a576b97e 100644 --- a/test/fetch/client-node-max-header-size.js +++ b/test/fetch/client-node-max-header-size.js @@ -1,13 +1,7 @@ 'use strict' const { execSync } = require('node:child_process') -const { test, skip } = require('tap') -const { nodeMajor } = require('../../lib/core/util') - -if (nodeMajor === 16) { - skip('esbuild uses static blocks with --keep-names which node 16.8 does not have') - process.exit() -} +const { test } = require('tap') const command = 'node -e "require(\'./undici-fetch.js\').fetch(\'https://httpbin.org/get\')"' diff --git a/test/fetch/issue-1447.js b/test/fetch/issue-1447.js index 503b34406d2..cfa5e94c0ed 100644 --- a/test/fetch/issue-1447.js +++ b/test/fetch/issue-1447.js @@ -1,12 +1,6 @@ 'use strict' -const { test, skip } = require('tap') -const { nodeMajor } = require('../../lib/core/util') - -if (nodeMajor === 16) { - skip('esbuild uses static blocks with --keep-names which node 16.8 does not have') - process.exit() -} +const { test } = require('tap') const undici = require('../..') const { fetch: theoreticalGlobalFetch } = require('../../undici-fetch') diff --git a/test/fetch/resource-timing.js b/test/fetch/resource-timing.js index d266f28bdc8..32753f57a86 100644 --- a/test/fetch/resource-timing.js +++ b/test/fetch/resource-timing.js @@ -10,7 +10,7 @@ const { performance } = require('perf_hooks') -const skip = nodeMajor < 18 || (nodeMajor === 18 && nodeMinor < 2) +const skip = nodeMajor === 18 && nodeMinor < 2 test('should create a PerformanceResourceTiming after each fetch request', { skip }, (t) => { t.plan(8) diff --git a/test/fetch/user-agent.js b/test/fetch/user-agent.js index 2e37ea5883d..604305959ff 100644 --- a/test/fetch/user-agent.js +++ b/test/fetch/user-agent.js @@ -1,15 +1,9 @@ 'use strict' -const { test, skip } = require('tap') +const { test } = require('tap') const events = require('events') const http = require('http') const undici = require('../../') -const { nodeMajor } = require('../../lib/core/util') - -if (nodeMajor === 16) { - skip('esbuild uses static blocks with --keep-names which node 16.8 does not have') - process.exit() -} const nodeBuild = require('../../undici-fetch.js') diff --git a/test/issue-1903.js b/test/issue-1903.js deleted file mode 100644 index 76ac81ef217..00000000000 --- a/test/issue-1903.js +++ /dev/null @@ -1,78 +0,0 @@ -'use strict' - -const { createServer } = require('http') -const { test } = require('tap') -const { request } = require('..') -const { nodeMajor } = require('../lib/core/util') - -function createPromise () { - const result = {} - result.promise = new Promise((resolve) => { - result.resolve = resolve - }) - return result -} - -test('should parse content-disposition consistently', { skip: nodeMajor >= 18 }, async (t) => { - t.plan(5) - - // create promise to allow server spinup in parallel - const spinup1 = createPromise() - const spinup2 = createPromise() - const spinup3 = createPromise() - - // variables to store content-disposition header - const header = [] - - const server = createServer((req, res) => { - res.writeHead(200, { - 'content-length': 2, - 'content-disposition': "attachment; filename='år.pdf'" - }) - header.push("attachment; filename='år.pdf'") - res.end('OK', spinup1.resolve) - }) - t.teardown(server.close.bind(server)) - server.listen(0, spinup1.resolve) - - const proxy1 = createServer(async (req, res) => { - const { statusCode, headers, body } = await request(`http://localhost:${server.address().port}`, { - method: 'GET' - }) - header.push(headers['content-disposition']) - delete headers['transfer-encoding'] - res.writeHead(statusCode, headers) - body.pipe(res) - }) - t.teardown(proxy1.close.bind(proxy1)) - proxy1.listen(0, spinup2.resolve) - - const proxy2 = createServer(async (req, res) => { - const { statusCode, headers, body } = await request(`http://localhost:${proxy1.address().port}`, { - method: 'GET' - }) - header.push(headers['content-disposition']) - delete headers['transfer-encoding'] - res.writeHead(statusCode, headers) - body.pipe(res) - }) - t.teardown(proxy2.close.bind(proxy2)) - proxy2.listen(0, spinup3.resolve) - - // wait until all server spinup - await Promise.all([spinup1.promise, spinup2.promise, spinup3.promise]) - - const { statusCode, headers, body } = await request(`http://localhost:${proxy2.address().port}`, { - method: 'GET' - }) - header.push(headers['content-disposition']) - t.equal(statusCode, 200) - t.equal(await body.text(), 'OK') - - // we check header - // must not be the same in first proxy - t.notSame(header[0], header[1]) - // chaining always the same value - t.equal(header[1], header[2]) - t.equal(header[2], header[3]) -}) diff --git a/test/issue-2065.js b/test/issue-2065.js index cc288c48a74..9cc015b9824 100644 --- a/test/issue-2065.js +++ b/test/issue-2065.js @@ -1,17 +1,11 @@ 'use strict' -const { test, skip } = require('tap') -const { nodeMajor, nodeMinor } = require('../lib/core/util') +const { test } = require('tap') const { createServer } = require('http') const { once } = require('events') const { createReadStream } = require('fs') const { File, FormData, request } = require('..') -if (nodeMajor < 16 || (nodeMajor === 16 && nodeMinor < 8)) { - skip('FormData is not available in node < v16.8.0') - process.exit() -} - test('undici.request with a FormData body should set content-length header', async (t) => { const server = createServer((req, res) => { t.ok(req.headers['content-length']) diff --git a/test/issue-2078.js b/test/issue-2078.js index d3aa868ef43..335d7ab3820 100644 --- a/test/issue-2078.js +++ b/test/issue-2078.js @@ -1,14 +1,8 @@ 'use strict' -const { test, skip } = require('tap') -const { nodeMajor, nodeMinor } = require('../lib/core/util') +const { test } = require('tap') const { MockAgent, getGlobalDispatcher, setGlobalDispatcher, fetch } = require('..') -if (nodeMajor < 16 || (nodeMajor === 16 && nodeMinor < 8)) { - skip('fetch is not supported in node < v16.8.0') - process.exit() -} - test('MockPool.reply headers are an object, not an array - issue #2078', async (t) => { const global = getGlobalDispatcher() const mockAgent = new MockAgent() diff --git a/test/issue-2349.js b/test/issue-2349.js index a82bb74a261..ae44543bb7a 100644 --- a/test/issue-2349.js +++ b/test/issue-2349.js @@ -1,15 +1,9 @@ 'use strict' -const { test, skip } = require('tap') -const { nodeMajor } = require('../lib/core/util') +const { test } = require('tap') const { Writable } = require('stream') const { MockAgent, errors, stream } = require('..') -if (nodeMajor < 16) { - skip('only for node 16') - process.exit(0) -} - test('stream() does not fail after request has been aborted', async (t) => { t.plan(1) diff --git a/test/jest/instanceof-error.test.js b/test/jest/instanceof-error.test.js index 8bb36d23c79..15f38ed5d02 100644 --- a/test/jest/instanceof-error.test.js +++ b/test/jest/instanceof-error.test.js @@ -8,10 +8,7 @@ const { once } = require('events') // https://github.com/facebook/jest/issues/11607#issuecomment-899068995 jest.useRealTimers() -const runIf = (condition) => condition ? it : it.skip -const nodeMajor = Number(process.versions.node.split('.', 1)[0]) - -runIf(nodeMajor >= 16)('isErrorLike sanity check', () => { +it('isErrorLike sanity check', () => { const { isErrorLike } = require('../../lib/fetch/util') const { DOMException } = require('../../lib/fetch/constants') const error = new DOMException('') @@ -21,7 +18,7 @@ runIf(nodeMajor >= 16)('isErrorLike sanity check', () => { expect(isErrorLike(error)).toBeTruthy() }) -runIf(nodeMajor >= 16)('Real use-case', async () => { +it('Real use-case', async () => { const { fetch } = require('../..') const ac = new AbortController() diff --git a/test/jest/issue-1757.test.js b/test/jest/issue-1757.test.js index b6519d9da14..e419e7c6c6b 100644 --- a/test/jest/issue-1757.test.js +++ b/test/jest/issue-1757.test.js @@ -23,10 +23,7 @@ class MiniflareDispatcher extends Dispatcher { } } -const runIf = (condition) => condition ? it : it.skip -const nodeMajor = Number(process.versions.node.split('.', 1)[0]) - -runIf(nodeMajor >= 16)('https://github.com/nodejs/undici/issues/1757', async () => { +it('https://github.com/nodejs/undici/issues/1757', async () => { // fetch isn't exported in <16.8 const { fetch } = require('../..') diff --git a/test/jest/mock-scope.test.js b/test/jest/mock-scope.test.js index cab77f6b112..f0b2378cbea 100644 --- a/test/jest/mock-scope.test.js +++ b/test/jest/mock-scope.test.js @@ -2,16 +2,13 @@ const { MockAgent, setGlobalDispatcher, request } = require('../../index') /* global afterAll, expect, it, AbortController */ -const runIf = (condition) => condition ? it : it.skip - -const nodeMajor = Number(process.versions.node.split('.', 1)[0]) const mockAgent = new MockAgent() afterAll(async () => { await mockAgent.close() }) -runIf(nodeMajor >= 16)('Jest works with MockScope.delay - issue #1327', async () => { +it('Jest works with MockScope.delay - issue #1327', async () => { mockAgent.disableNetConnect() setGlobalDispatcher(mockAgent) diff --git a/test/mock-agent.js b/test/mock-agent.js index 920605797d3..7c1ff660622 100644 --- a/test/mock-agent.js +++ b/test/mock-agent.js @@ -7,12 +7,12 @@ const { request, setGlobalDispatcher, MockAgent, Agent } = require('..') const { getResponse } = require('../lib/mock/mock-utils') const { kClients, kConnected } = require('../lib/core/symbols') const { InvalidArgumentError, ClientDestroyedError } = require('../lib/core/errors') -const { nodeMajor } = require('../lib/core/util') const MockClient = require('../lib/mock/mock-client') const MockPool = require('../lib/mock/mock-pool') const { kAgent } = require('../lib/mock/mock-symbols') const Dispatcher = require('../lib/dispatcher') const { MockNotMatchedError } = require('../lib/mock/mock-errors') +const { fetch } = require('..') test('MockAgent - constructor', t => { t.plan(5) @@ -2399,9 +2399,7 @@ test('MockAgent - clients are not garbage collected', async (t) => { }) // https://github.com/nodejs/undici/issues/1321 -test('MockAgent - using fetch yields correct statusText', { skip: nodeMajor < 16 }, async (t) => { - const { fetch } = require('..') - +test('MockAgent - using fetch yields correct statusText', async (t) => { const mockAgent = new MockAgent() mockAgent.disableNetConnect() setGlobalDispatcher(mockAgent) @@ -2432,9 +2430,7 @@ test('MockAgent - using fetch yields correct statusText', { skip: nodeMajor < 16 }) // https://github.com/nodejs/undici/issues/1556 -test('MockAgent - using fetch yields a headers object in the reply callback', { skip: nodeMajor < 16 }, async (t) => { - const { fetch } = require('..') - +test('MockAgent - using fetch yields a headers object in the reply callback', async (t) => { const mockAgent = new MockAgent() mockAgent.disableNetConnect() t.teardown(mockAgent.close.bind(mockAgent)) @@ -2464,9 +2460,7 @@ test('MockAgent - using fetch yields a headers object in the reply callback', { }) // https://github.com/nodejs/undici/issues/1579 -test('MockAgent - headers in mock dispatcher intercept should be case-insensitive', { skip: nodeMajor < 16 }, async (t) => { - const { fetch } = require('..') - +test('MockAgent - headers in mock dispatcher intercept should be case-insensitive', async (t) => { const mockAgent = new MockAgent() mockAgent.disableNetConnect() setGlobalDispatcher(mockAgent) @@ -2495,9 +2489,7 @@ test('MockAgent - headers in mock dispatcher intercept should be case-insensitiv }) // https://github.com/nodejs/undici/issues/1757 -test('MockAgent - reply callback can be asynchronous', { skip: nodeMajor < 16 }, async (t) => { - const { fetch } = require('..') - +test('MockAgent - reply callback can be asynchronous', async (t) => { class MiniflareDispatcher extends Dispatcher { constructor (inner, options) { super(options) @@ -2601,9 +2593,8 @@ test('MockAgent - headers should be array of strings', async (t) => { }) // https://github.com/nodejs/undici/issues/2418 -test('MockAgent - Sending ReadableStream body', { skip: nodeMajor < 16 }, async (t) => { +test('MockAgent - Sending ReadableStream body', async (t) => { t.plan(1) - const { fetch } = require('..') const mockAgent = new MockAgent() setGlobalDispatcher(mockAgent) diff --git a/test/mock-pool.js b/test/mock-pool.js index 0ac1aac49ce..682d02aab68 100644 --- a/test/mock-pool.js +++ b/test/mock-pool.js @@ -5,12 +5,12 @@ const { createServer } = require('http') const { promisify } = require('util') const { MockAgent, MockPool, getGlobalDispatcher, setGlobalDispatcher, request } = require('..') const { kUrl } = require('../lib/core/symbols') -const { nodeMajor } = require('../lib/core/util') const { kDispatches } = require('../lib/mock/mock-symbols') const { InvalidArgumentError } = require('../lib/core/errors') const { MockInterceptor } = require('../lib/mock/mock-interceptor') const { getResponse } = require('../lib/mock/mock-utils') const Dispatcher = require('../lib/dispatcher') +const { fetch } = require('..') test('MockPool - constructor', t => { t.plan(3) @@ -323,9 +323,7 @@ test('MockPool - correct errors when consuming invalid JSON body', async (t) => t.end() }) -test('MockPool - allows matching headers in fetch', { skip: nodeMajor < 16 }, async (t) => { - const { fetch } = require('../index') - +test('MockPool - allows matching headers in fetch', async (t) => { const oldDispatcher = getGlobalDispatcher() const baseUrl = 'http://localhost:9999' diff --git a/test/mock-utils.js b/test/mock-utils.js index 7799803ad2f..4acc8558390 100644 --- a/test/mock-utils.js +++ b/test/mock-utils.js @@ -1,7 +1,6 @@ 'use strict' const { test } = require('tap') -const { nodeMajor } = require('../lib/core/util') const { MockNotMatchedError } = require('../lib/mock/mock-errors') const { deleteMockDispatch, @@ -145,16 +144,14 @@ test('getHeaderByName', (t) => { t.equal(getHeaderByName(headersArray, 'key'), 'value') t.equal(getHeaderByName(headersArray, 'anotherKey'), undefined) - if (nodeMajor >= 16) { - const { Headers } = require('../index') + const { Headers } = require('../index') - const headers = new Headers([ - ['key', 'value'] - ]) + const headers = new Headers([ + ['key', 'value'] + ]) - t.equal(getHeaderByName(headers, 'key'), 'value') - t.equal(getHeaderByName(headers, 'anotherKey'), null) - } + t.equal(getHeaderByName(headers, 'key'), 'value') + t.equal(getHeaderByName(headers, 'anotherKey'), null) t.end() }) diff --git a/test/proxy-agent.js b/test/proxy-agent.js index 0a9212639f8..7177ef8735a 100644 --- a/test/proxy-agent.js +++ b/test/proxy-agent.js @@ -3,7 +3,6 @@ const { test, teardown } = require('tap') const { request, fetch, setGlobalDispatcher, getGlobalDispatcher } = require('..') const { InvalidArgumentError } = require('../lib/core/errors') -const { nodeMajor } = require('../lib/core/util') const { readFileSync } = require('fs') const { join } = require('path') const ProxyAgent = require('../lib/proxy-agent') @@ -367,7 +366,7 @@ test('use proxy-agent with setGlobalDispatcher', async (t) => { proxyAgent.close() }) -test('ProxyAgent correctly sends headers when using fetch - #1355, #1623', { skip: nodeMajor < 16 }, async (t) => { +test('ProxyAgent correctly sends headers when using fetch - #1355, #1623', async (t) => { t.plan(2) const defaultDispatcher = getGlobalDispatcher() @@ -443,7 +442,7 @@ test('should throw when proxy does not return 200', async (t) => { t.end() }) -test('pass ProxyAgent proxy status code error when using fetch - #2161', { skip: nodeMajor < 16 }, async (t) => { +test('pass ProxyAgent proxy status code error when using fetch - #2161', async (t) => { const server = await buildServer() const proxy = await buildProxy() diff --git a/test/redirect-request.js b/test/redirect-request.js index 5a1ae6de5b4..a51166adb76 100644 --- a/test/redirect-request.js +++ b/test/redirect-request.js @@ -2,7 +2,6 @@ const t = require('tap') const undici = require('..') -const { nodeMajor } = require('../lib/core/util') const { startRedirectingServer, startRedirectingWithBodyServer, @@ -312,7 +311,7 @@ for (const factory of [ } }) - t.test('should not follow redirects when using ReadableStream request bodies', { skip: nodeMajor < 16 }, async t => { + t.test('should not follow redirects when using ReadableStream request bodies', async t => { const server = await startRedirectingServer(t) const { statusCode, headers, body: bodyStream } = await request(t, server, undefined, `http://${server}/301`, { diff --git a/test/request-timeout.js b/test/request-timeout.js index 3ec5c107e79..23115ea4b9e 100644 --- a/test/request-timeout.js +++ b/test/request-timeout.js @@ -4,7 +4,6 @@ const { test } = require('tap') const { createReadStream, writeFileSync, unlinkSync } = require('fs') const { Client, errors } = require('..') const { kConnect } = require('../lib/core/symbols') -const { nodeMajor } = require('../lib/core/util') const timers = require('../lib/timers') const { createServer } = require('http') const EventEmitter = require('events') @@ -57,7 +56,7 @@ test('request timeout with readable body', (t) => { t.type(err, errors.HeadersTimeoutError) }) }) -}, { skip: nodeMajor < 14 }) +}) test('body timeout', (t) => { t.plan(2) diff --git a/test/tls-client-cert.js b/test/tls-client-cert.js deleted file mode 100644 index 8ae301d8fca..00000000000 --- a/test/tls-client-cert.js +++ /dev/null @@ -1,70 +0,0 @@ -'use strict' - -const { readFileSync } = require('fs') -const { join } = require('path') -const https = require('https') -const { test } = require('tap') -const { Client } = require('..') -const { kSocket } = require('../lib/core/symbols') -const { nodeMajor } = require('../lib/core/util') - -const serverOptions = { - ca: [ - readFileSync(join(__dirname, 'fixtures', 'client-ca-crt.pem'), 'utf8') - ], - key: readFileSync(join(__dirname, 'fixtures', 'key.pem'), 'utf8'), - cert: readFileSync(join(__dirname, 'fixtures', 'cert.pem'), 'utf8'), - requestCert: true, - rejectUnauthorized: false -} - -test('Client using valid client certificate', { skip: nodeMajor > 16 }, t => { - t.plan(5) - - const server = https.createServer(serverOptions, (req, res) => { - const authorized = req.client.authorized - t.ok(authorized) - - res.setHeader('Content-Type', 'text/plain') - res.end('hello') - }) - - server.listen(0, function () { - const tls = { - ca: [ - readFileSync(join(__dirname, 'fixtures', 'ca.pem'), 'utf8') - ], - key: readFileSync(join(__dirname, 'fixtures', 'client-key.pem'), 'utf8'), - cert: readFileSync(join(__dirname, 'fixtures', 'client-crt.pem'), 'utf8'), - rejectUnauthorized: false, - servername: 'agent1' - } - const client = new Client(`https://localhost:${server.address().port}`, { - connect: tls - }) - - t.teardown(() => { - client.close() - server.close() - }) - - client.request({ - path: '/', - method: 'GET' - }, (err, { statusCode, body }) => { - t.error(err) - t.equal(statusCode, 200) - - const authorized = client[kSocket].authorized - t.ok(authorized) - - const bufs = [] - body.on('data', (buf) => { - bufs.push(buf) - }) - body.on('end', () => { - t.equal('hello', Buffer.concat(bufs).toString('utf8')) - }) - }) - }) -}) diff --git a/test/tls-session-reuse.js b/test/tls-session-reuse.js index ab012f16756..7a7657b4e4c 100644 --- a/test/tls-session-reuse.js +++ b/test/tls-session-reuse.js @@ -7,7 +7,6 @@ const crypto = require('crypto') const { test, teardown } = require('tap') const { Client, Pool } = require('..') const { kSocket } = require('../lib/core/symbols') -const { nodeMajor } = require('../lib/core/util') const options = { key: readFileSync(join(__dirname, 'fixtures', 'key.pem'), 'utf8'), @@ -15,9 +14,7 @@ const options = { } const ca = readFileSync(join(__dirname, 'fixtures', 'ca.pem'), 'utf8') -test('A client should disable session caching', { - skip: nodeMajor < 11 // tls socket session event has been added in Node 11. Cf. https://nodejs.org/api/tls.html#tls_event_session -}, t => { +test('A client should disable session caching', t => { const clientSessions = {} let serverRequests = 0 @@ -93,9 +90,7 @@ test('A client should disable session caching', { t.end() }) -test('A pool should be able to reuse TLS sessions between clients', { - skip: nodeMajor < 11 // tls socket session event has been added in Node 11. Cf. https://nodejs.org/api/tls.html#tls_event_session -}, t => { +test('A pool should be able to reuse TLS sessions between clients', t => { let serverRequests = 0 const REQ_COUNT = 10 diff --git a/test/util.js b/test/util.js index 794c68e3f77..cd5c4ed3044 100644 --- a/test/util.js +++ b/test/util.js @@ -97,7 +97,7 @@ test('parseRawHeaders', (t) => { t.same(util.parseRawHeaders(['key', 'value', Buffer.from('key'), Buffer.from('value')]), ['key', 'value', 'key', 'value']) }) -test('buildURL', { skip: util.nodeMajor >= 12 }, (t) => { +test('buildURL', (t) => { const tests = [ [{ id: BigInt(123456) }, 'id=123456'], [{ date: new Date() }, 'date='], From b10c0db8efc06953693d73d142a992c64db6cab0 Mon Sep 17 00:00:00 2001 From: Khafra Date: Fri, 1 Dec 2023 18:07:11 -0500 Subject: [PATCH 3/3] remove DOMException, structuredClone, WeakRef, FinalizationRegistry workarounds --- README.md | 2 -- lib/compat/dispatcher-weakref.js | 7 +----- lib/fetch/body.js | 1 - lib/fetch/constants.js | 36 ------------------------------ lib/fetch/index.js | 3 +-- lib/fetch/response.js | 3 +-- lib/fetch/util.js | 6 ----- lib/fetch/webidl.js | 6 ++--- lib/fileapi/util.js | 1 - lib/websocket/websocket.js | 1 - test/fetch/abort.js | 1 - test/fetch/abort2.js | 1 - test/fetch/issue-2171.js | 1 - test/jest/instanceof-error.test.js | 1 - 14 files changed, 6 insertions(+), 64 deletions(-) diff --git a/README.md b/README.md index 3ba89890df6..cec6f032e99 100644 --- a/README.md +++ b/README.md @@ -180,8 +180,6 @@ Implements [fetch](https://fetch.spec.whatwg.org/#fetch-method). * https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch * https://fetch.spec.whatwg.org/#fetch-method -Only supported on Node 16.8+. - Basic usage example: ```js diff --git a/lib/compat/dispatcher-weakref.js b/lib/compat/dispatcher-weakref.js index 8cb99e21501..a2fd0020416 100644 --- a/lib/compat/dispatcher-weakref.js +++ b/lib/compat/dispatcher-weakref.js @@ -1,7 +1,5 @@ 'use strict' -/* istanbul ignore file: only for Node 12 */ - const { kConnected, kSize } = require('../core/symbols') class CompatWeakRef { @@ -41,8 +39,5 @@ module.exports = function () { FinalizationRegistry: CompatFinalizer } } - return { - WeakRef: global.WeakRef || CompatWeakRef, - FinalizationRegistry: global.FinalizationRegistry || CompatFinalizer - } + return { WeakRef, FinalizationRegistry } } diff --git a/lib/fetch/body.js b/lib/fetch/body.js index cf7f07996de..2a8b38f7415 100644 --- a/lib/fetch/body.js +++ b/lib/fetch/body.js @@ -13,7 +13,6 @@ const { const { FormData } = require('./formdata') const { kState } = require('./symbols') const { webidl } = require('./webidl') -const { DOMException, structuredClone } = require('./constants') const { Blob, File: NativeFile } = require('buffer') const { kBodyUsed } = require('../core/symbols') const assert = require('assert') diff --git a/lib/fetch/constants.js b/lib/fetch/constants.js index 218fcbee4da..ada622feed5 100644 --- a/lib/fetch/constants.js +++ b/lib/fetch/constants.js @@ -1,7 +1,5 @@ 'use strict' -const { MessageChannel, receiveMessageOnPort } = require('worker_threads') - const corsSafeListedMethods = ['GET', 'HEAD', 'POST'] const corsSafeListedMethodsSet = new Set(corsSafeListedMethods) @@ -92,41 +90,7 @@ const subresource = [ ] const subresourceSet = new Set(subresource) -/** @type {globalThis['DOMException']} */ -const DOMException = globalThis.DOMException ?? (() => { - // DOMException was only made a global in Node v17.0.0, - // but fetch supports >= v16.8. - try { - atob('~') - } catch (err) { - return Object.getPrototypeOf(err).constructor - } -})() - -let channel - -/** @type {globalThis['structuredClone']} */ -const structuredClone = - globalThis.structuredClone ?? - // https://github.com/nodejs/node/blob/b27ae24dcc4251bad726d9d84baf678d1f707fed/lib/internal/structured_clone.js - // structuredClone was added in v17.0.0, but fetch supports v16.8 - function structuredClone (value, options = undefined) { - if (arguments.length === 0) { - throw new TypeError('missing argument') - } - - if (!channel) { - channel = new MessageChannel() - } - channel.port1.unref() - channel.port2.unref() - channel.port1.postMessage(value, options?.transfer) - return receiveMessageOnPort(channel.port2).message - } - module.exports = { - DOMException, - structuredClone, subresource, forbiddenMethods, requestBodyHeader, diff --git a/lib/fetch/index.js b/lib/fetch/index.js index 7c006350b1c..01db3aeb65f 100644 --- a/lib/fetch/index.js +++ b/lib/fetch/index.js @@ -52,8 +52,7 @@ const { nullBodyStatus, safeMethodsSet, requestBodyHeader, - subresourceSet, - DOMException + subresourceSet } = require('./constants') const { kHeadersList } = require('../core/symbols') const EE = require('events') diff --git a/lib/fetch/response.js b/lib/fetch/response.js index af4f34a2f3b..8f647cc708b 100644 --- a/lib/fetch/response.js +++ b/lib/fetch/response.js @@ -15,8 +15,7 @@ const { } = require('./util') const { redirectStatusSet, - nullBodyStatus, - DOMException + nullBodyStatus } = require('./constants') const { kState, kHeaders, kGuard, kRealm } = require('./symbols') const { webidl } = require('./webidl') diff --git a/lib/fetch/util.js b/lib/fetch/util.js index c1b26d0b511..96711267681 100644 --- a/lib/fetch/util.js +++ b/lib/fetch/util.js @@ -1179,11 +1179,6 @@ function buildContentRange (rangeStart, rangeEnd, fullLength) { return contentRange } -/** - * Fetch supports node >= 16.8.0, but Object.hasOwn was added in v16.9.0. - */ -const hasOwn = Object.hasOwn || ((dict, key) => Object.prototype.hasOwnProperty.call(dict, key)) - module.exports = { isAborted, isCancelled, @@ -1216,7 +1211,6 @@ module.exports = { makeIterator, isValidHeaderName, isValidHeaderValue, - hasOwn, isErrorLike, fullyReadBody, bytesMatch, diff --git a/lib/fetch/webidl.js b/lib/fetch/webidl.js index 6fcf2ab6ad4..ca1019221d9 100644 --- a/lib/fetch/webidl.js +++ b/lib/fetch/webidl.js @@ -1,7 +1,7 @@ 'use strict' const { types } = require('util') -const { hasOwn, toUSVString } = require('./util') +const { toUSVString } = require('./util') /** @type {import('../../types/webidl').Webidl} */ const webidl = {} @@ -346,7 +346,7 @@ webidl.dictionaryConverter = function (converters) { const { key, defaultValue, required, converter } = options if (required === true) { - if (!hasOwn(dictionary, key)) { + if (!Object.hasOwn(dictionary, key)) { throw webidl.errors.exception({ header: 'Dictionary', message: `Missing required key "${key}".` @@ -355,7 +355,7 @@ webidl.dictionaryConverter = function (converters) { } let value = dictionary[key] - const hasDefault = hasOwn(options, 'defaultValue') + const hasDefault = Object.hasOwn(options, 'defaultValue') // Only use defaultValue if value is undefined and // a defaultValue options was provided. diff --git a/lib/fileapi/util.js b/lib/fileapi/util.js index 1d10899cee8..a29423d9d14 100644 --- a/lib/fileapi/util.js +++ b/lib/fileapi/util.js @@ -9,7 +9,6 @@ const { } = require('./symbols') const { ProgressEvent } = require('./progressevent') const { getEncoding } = require('./encoding') -const { DOMException } = require('../fetch/constants') const { serializeAMimeType, parseMIMEType } = require('../fetch/dataURL') const { types } = require('util') const { StringDecoder } = require('string_decoder') diff --git a/lib/websocket/websocket.js b/lib/websocket/websocket.js index e4aa58f52fc..1eac67b7828 100644 --- a/lib/websocket/websocket.js +++ b/lib/websocket/websocket.js @@ -1,7 +1,6 @@ 'use strict' const { webidl } = require('../fetch/webidl') -const { DOMException } = require('../fetch/constants') const { URLSerializer } = require('../fetch/dataURL') const { getGlobalOrigin } = require('../fetch/global') const { staticPropertyDescriptors, states, opcodes, emptyBuffer } = require('./constants') diff --git a/test/fetch/abort.js b/test/fetch/abort.js index 95b51a0f827..367201f3a16 100644 --- a/test/fetch/abort.js +++ b/test/fetch/abort.js @@ -4,7 +4,6 @@ const { test } = require('tap') const { fetch } = require('../..') const { createServer } = require('http') const { once } = require('events') -const { DOMException } = require('../../lib/fetch/constants') const { AbortController: NPMAbortController } = require('abort-controller') diff --git a/test/fetch/abort2.js b/test/fetch/abort2.js index 5f3853bcb7a..b07482d9706 100644 --- a/test/fetch/abort2.js +++ b/test/fetch/abort2.js @@ -4,7 +4,6 @@ const { test } = require('tap') const { fetch } = require('../..') const { createServer } = require('http') const { once } = require('events') -const { DOMException } = require('../../lib/fetch/constants') /* global AbortController */ diff --git a/test/fetch/issue-2171.js b/test/fetch/issue-2171.js index b04ae0e6c38..72770f3713f 100644 --- a/test/fetch/issue-2171.js +++ b/test/fetch/issue-2171.js @@ -1,7 +1,6 @@ 'use strict' const { fetch } = require('../..') -const { DOMException } = require('../../lib/fetch/constants') const { once } = require('events') const { createServer } = require('http') const { test } = require('tap') diff --git a/test/jest/instanceof-error.test.js b/test/jest/instanceof-error.test.js index 15f38ed5d02..2fa71565172 100644 --- a/test/jest/instanceof-error.test.js +++ b/test/jest/instanceof-error.test.js @@ -10,7 +10,6 @@ jest.useRealTimers() it('isErrorLike sanity check', () => { const { isErrorLike } = require('../../lib/fetch/util') - const { DOMException } = require('../../lib/fetch/constants') const error = new DOMException('') // https://github.com/facebook/jest/issues/2549