diff --git a/benchmarks/benchmark-http2.js b/benchmarks/benchmark-http2.js index 8d9716d4b59..812fcea2e87 100644 --- a/benchmarks/benchmark-http2.js +++ b/benchmarks/benchmark-http2.js @@ -1,12 +1,12 @@ 'use strict' -const { connect } = require('http2') -const { createSecureContext } = require('tls') -const os = require('os') -const path = require('path') -const { readFileSync } = require('fs') -const { Writable } = require('stream') -const { isMainThread } = require('worker_threads') +const { connect } = require('node:http2') +const { createSecureContext } = require('node:tls') +const os = require('node:os') +const path = require('node:path') +const { readFileSync } = require('node:fs') +const { Writable } = require('node:stream') +const { isMainThread } = require('node:worker_threads') const { Pool, Client, fetch, Agent, setGlobalDispatcher } = require('..') diff --git a/benchmarks/benchmark-https.js b/benchmarks/benchmark-https.js index 644f019c37d..2f662bfbb54 100644 --- a/benchmarks/benchmark-https.js +++ b/benchmarks/benchmark-https.js @@ -1,11 +1,11 @@ 'use strict' -const https = require('https') -const os = require('os') -const path = require('path') -const { readFileSync } = require('fs') -const { Writable } = require('stream') -const { isMainThread } = require('worker_threads') +const https = require('node:https') +const os = require('node:os') +const path = require('node:path') +const { readFileSync } = require('node:fs') +const { Writable } = require('node:stream') +const { isMainThread } = require('node:worker_threads') const { Pool, Client, fetch, Agent, setGlobalDispatcher } = require('..') diff --git a/benchmarks/benchmark.js b/benchmarks/benchmark.js index 77b814c98e3..32b761a8a56 100644 --- a/benchmarks/benchmark.js +++ b/benchmarks/benchmark.js @@ -1,10 +1,10 @@ 'use strict' -const http = require('http') -const os = require('os') -const path = require('path') -const { Writable } = require('stream') -const { isMainThread } = require('worker_threads') +const http = require('node:http') +const os = require('node:os') +const path = require('node:path') +const { Writable } = require('node:stream') +const { isMainThread } = require('node:worker_threads') const { Pool, Client, fetch, Agent, setGlobalDispatcher } = require('..') @@ -12,7 +12,7 @@ let nodeFetch const axios = require('axios') let got -const util = require('util') +const util = require('node:util') const _request = require('request') const request = util.promisify(_request) diff --git a/benchmarks/server-http2.js b/benchmarks/server-http2.js index 0be99cd2fd7..f8183b2fa1a 100644 --- a/benchmarks/server-http2.js +++ b/benchmarks/server-http2.js @@ -1,10 +1,10 @@ 'use strict' -const { unlinkSync, readFileSync } = require('fs') -const { createSecureServer } = require('http2') -const os = require('os') -const path = require('path') -const cluster = require('cluster') +const { unlinkSync, readFileSync } = require('node:fs') +const { createSecureServer } = require('node:http2') +const os = require('node:os') +const path = require('node:path') +const cluster = require('node:cluster') const key = readFileSync(path.join(__dirname, '..', 'test', 'fixtures', 'key.pem'), 'utf8') const cert = readFileSync(path.join(__dirname, '..', 'test', 'fixtures', 'cert.pem'), 'utf8') diff --git a/benchmarks/server-https.js b/benchmarks/server-https.js index f0275d9cbcc..350ec2e3328 100644 --- a/benchmarks/server-https.js +++ b/benchmarks/server-https.js @@ -1,10 +1,10 @@ 'use strict' -const { unlinkSync, readFileSync } = require('fs') -const { createServer } = require('https') -const os = require('os') -const path = require('path') -const cluster = require('cluster') +const { unlinkSync, readFileSync } = require('node:fs') +const { createServer } = require('node:https') +const os = require('node:os') +const path = require('node:path') +const cluster = require('node:cluster') const key = readFileSync(path.join(__dirname, '..', 'test', 'fixtures', 'key.pem'), 'utf8') const cert = readFileSync(path.join(__dirname, '..', 'test', 'fixtures', 'cert.pem'), 'utf8') diff --git a/benchmarks/server.js b/benchmarks/server.js index e1a32e838e9..b6aaa8df52e 100644 --- a/benchmarks/server.js +++ b/benchmarks/server.js @@ -1,10 +1,10 @@ 'use strict' -const { unlinkSync } = require('fs') -const { createServer } = require('http') -const os = require('os') -const path = require('path') -const cluster = require('cluster') +const { unlinkSync } = require('node:fs') +const { createServer } = require('node:http') +const os = require('node:os') +const path = require('node:path') +const cluster = require('node:cluster') const socketPath = path.join(os.tmpdir(), 'undici.sock') diff --git a/benchmarks/wait.js b/benchmarks/wait.js index 771f9f2626c..95b9377021c 100644 --- a/benchmarks/wait.js +++ b/benchmarks/wait.js @@ -1,7 +1,7 @@ 'use strict' -const os = require('os') -const path = require('path') +const os = require('node:os') +const path = require('node:path') const waitOn = require('wait-on') const socketPath = path.join(os.tmpdir(), 'undici.sock') diff --git a/build/wasm.js b/build/wasm.js index 1104cfec0b0..3fb8f103117 100644 --- a/build/wasm.js +++ b/build/wasm.js @@ -1,8 +1,8 @@ 'use strict' -const { execSync } = require('child_process') -const { writeFileSync, readFileSync } = require('fs') -const { join, resolve, basename } = require('path') +const { execSync } = require('node:child_process') +const { writeFileSync, readFileSync } = require('node:fs') +const { join, resolve, basename } = require('node:path') const ROOT = resolve(__dirname, '../') const WASM_SRC = resolve(__dirname, '../deps/llhttp') diff --git a/docs/best-practices/client-certificate.md b/docs/best-practices/client-certificate.md index 4fc84ece50d..9ead733af9e 100644 --- a/docs/best-practices/client-certificate.md +++ b/docs/best-practices/client-certificate.md @@ -11,9 +11,9 @@ The server option `rejectUnauthorized: false` allows us to handle any invalid ce ### Client Certificate Authentication ```js -const { readFileSync } = require('fs') -const { join } = require('path') -const { createServer } = require('https') +const { readFileSync } = require('node:fs') +const { join } = require('node:path') +const { createServer } = require('node:https') const { Client } = require('undici') const serverOptions = { diff --git a/examples/README.md b/examples/README.md index 60965c2898a..b175b9daed7 100644 --- a/examples/README.md +++ b/examples/README.md @@ -49,7 +49,7 @@ async function postJSONRequest (port = 3001) { const { request } = require('undici') async function postFormRequest (port = 3001) { // Make a URL-encoded form POST request: - const qs = require('querystring') + const qs = require('node:querystring') const requestBody = { hello: 'URL Encoded Example body' diff --git a/examples/ca-fingerprint/index.js b/examples/ca-fingerprint/index.js index 792c08c64b1..7fa6a5ac0fa 100644 --- a/examples/ca-fingerprint/index.js +++ b/examples/ca-fingerprint/index.js @@ -1,7 +1,7 @@ 'use strict' -const crypto = require('crypto') -const https = require('https') +const crypto = require('node:crypto') +const https = require('node:https') const { Client, buildConnector } = require('../..') const pem = require('https-pem') diff --git a/examples/eventsource.js b/examples/eventsource.js index a9cb323dc86..ca280cb4129 100644 --- a/examples/eventsource.js +++ b/examples/eventsource.js @@ -1,6 +1,6 @@ 'use strict' -const { randomBytes } = require('crypto') +const { randomBytes } = require('node:crypto') const { EventSource } = require('../') async function main () { diff --git a/examples/proxy/index.js b/examples/proxy/index.js index 4cf8bc61b16..16aeaeeaba3 100644 --- a/examples/proxy/index.js +++ b/examples/proxy/index.js @@ -1,5 +1,5 @@ const { Pool, Client } = require('../../') -const http = require('http') +const http = require('node:http') const proxy = require('./proxy') const pool = new Pool('http://localhost:4001', { diff --git a/examples/proxy/proxy.js b/examples/proxy/proxy.js index bb9fcc43418..6c16a5e70b0 100644 --- a/examples/proxy/proxy.js +++ b/examples/proxy/proxy.js @@ -1,5 +1,5 @@ -const net = require('net') -const { pipeline } = require('stream') +const net = require('node:net') +const { pipeline } = require('node:stream') const createError = require('http-errors') module.exports = async function proxy (ctx, client) { diff --git a/examples/proxy/websocket.js b/examples/proxy/websocket.js index 324d0531c57..f21cafdc838 100644 --- a/examples/proxy/websocket.js +++ b/examples/proxy/websocket.js @@ -1,5 +1,5 @@ const { Pool, Client } = require('../../') -const http = require('http') +const http = require('node:http') const proxy = require('./proxy') const WebSocket = require('ws') diff --git a/examples/request.js b/examples/request.js index 01dcf58b03b..aa3a86e849e 100644 --- a/examples/request.js +++ b/examples/request.js @@ -41,7 +41,7 @@ async function postJSONRequest (port = 3001) { async function postFormRequest (port = 3001) { // Make a URL-encoded form POST request: - const qs = require('querystring') + const qs = require('node:querystring') const requestBody = { hello: 'URL Encoded Example body' diff --git a/lib/api/api-connect.js b/lib/api/api-connect.js index fd2b6ad97a5..9a144fb62ba 100644 --- a/lib/api/api-connect.js +++ b/lib/api/api-connect.js @@ -1,6 +1,6 @@ 'use strict' -const { AsyncResource } = require('async_hooks') +const { AsyncResource } = require('node:async_hooks') const { InvalidArgumentError, RequestAbortedError, SocketError } = require('../core/errors') const util = require('../core/util') const { addSignal, removeSignal } = require('./abort-signal') diff --git a/lib/api/api-pipeline.js b/lib/api/api-pipeline.js index af4a1803b44..7b48e952b12 100644 --- a/lib/api/api-pipeline.js +++ b/lib/api/api-pipeline.js @@ -4,16 +4,16 @@ const { Readable, Duplex, PassThrough -} = require('stream') +} = require('node:stream') const { InvalidArgumentError, InvalidReturnValueError, RequestAbortedError } = require('../core/errors') const util = require('../core/util') -const { AsyncResource } = require('async_hooks') +const { AsyncResource } = require('node:async_hooks') const { addSignal, removeSignal } = require('./abort-signal') -const assert = require('assert') +const assert = require('node:assert') const kResume = Symbol('resume') diff --git a/lib/api/api-request.js b/lib/api/api-request.js index d4281ce2449..39aa4c32cce 100644 --- a/lib/api/api-request.js +++ b/lib/api/api-request.js @@ -7,7 +7,7 @@ const { } = require('../core/errors') const util = require('../core/util') const { getResolveErrorBodyCallback } = require('./util') -const { AsyncResource } = require('async_hooks') +const { AsyncResource } = require('node:async_hooks') const { addSignal, removeSignal } = require('./abort-signal') class RequestHandler extends AsyncResource { diff --git a/lib/api/api-stream.js b/lib/api/api-stream.js index c571a6f79a7..58c74188420 100644 --- a/lib/api/api-stream.js +++ b/lib/api/api-stream.js @@ -1,6 +1,6 @@ 'use strict' -const { finished, PassThrough } = require('stream') +const { finished, PassThrough } = require('node:stream') const { InvalidArgumentError, InvalidReturnValueError, @@ -8,7 +8,7 @@ const { } = require('../core/errors') const util = require('../core/util') const { getResolveErrorBodyCallback } = require('./util') -const { AsyncResource } = require('async_hooks') +const { AsyncResource } = require('node:async_hooks') const { addSignal, removeSignal } = require('./abort-signal') class StreamHandler extends AsyncResource { diff --git a/lib/api/api-upgrade.js b/lib/api/api-upgrade.js index ef783e82975..52767a36e4a 100644 --- a/lib/api/api-upgrade.js +++ b/lib/api/api-upgrade.js @@ -1,10 +1,10 @@ 'use strict' const { InvalidArgumentError, RequestAbortedError, SocketError } = require('../core/errors') -const { AsyncResource } = require('async_hooks') +const { AsyncResource } = require('node:async_hooks') const util = require('../core/util') const { addSignal, removeSignal } = require('./abort-signal') -const assert = require('assert') +const assert = require('node:assert') class UpgradeHandler extends AsyncResource { constructor (opts, callback) { diff --git a/lib/api/readable.js b/lib/api/readable.js index cd4811591a7..25b40c109c0 100644 --- a/lib/api/readable.js +++ b/lib/api/readable.js @@ -2,8 +2,8 @@ 'use strict' -const assert = require('assert') -const { Readable } = require('stream') +const assert = require('node:assert') +const { Readable } = require('node:stream') const { RequestAbortedError, NotSupportedError, InvalidArgumentError, AbortError } = require('../core/errors') const util = require('../core/util') const { ReadableStreamFrom } = require('../core/util') diff --git a/lib/api/util.js b/lib/api/util.js index bffd70279a4..60f001b2254 100644 --- a/lib/api/util.js +++ b/lib/api/util.js @@ -1,4 +1,4 @@ -const assert = require('assert') +const assert = require('node:assert') const { ResponseStatusCodeError } = require('../core/errors') diff --git a/lib/cache/cache.js b/lib/cache/cache.js index a36ed6c23ae..d49393d15bc 100644 --- a/lib/cache/cache.js +++ b/lib/cache/cache.js @@ -9,7 +9,7 @@ const { Request, fromInnerRequest } = require('../fetch/request') const { kState } = require('../fetch/symbols') const { fetching } = require('../fetch/index') const { urlIsHttpHttpsScheme, createDeferredPromise, readAllBytes } = require('../fetch/util') -const assert = require('assert') +const assert = require('node:assert') const { getGlobalDispatcher } = require('../global') /** diff --git a/lib/cache/util.js b/lib/cache/util.js index 44d52b789ed..eba8a60efa3 100644 --- a/lib/cache/util.js +++ b/lib/cache/util.js @@ -1,6 +1,6 @@ 'use strict' -const assert = require('assert') +const assert = require('node:assert') const { URLSerializer } = require('../fetch/dataURL') const { isValidHeaderName } = require('../fetch/util') diff --git a/lib/client.js b/lib/client.js index a46a1504b54..b753df0d906 100644 --- a/lib/client.js +++ b/lib/client.js @@ -4,10 +4,10 @@ /* global WebAssembly */ -const assert = require('assert') -const net = require('net') -const http = require('http') -const { pipeline } = require('stream') +const assert = require('node:assert') +const net = require('node:net') +const http = require('node:http') +const { pipeline } = require('node:stream') const util = require('./core/util') const { channels } = require('./core/diagnostics') const timers = require('./timers') @@ -84,7 +84,7 @@ const { /** @type {import('http2')} */ let http2 try { - http2 = require('http2') + http2 = require('node:http2') } catch { // @ts-ignore http2 = { constants: {} } diff --git a/lib/cookies/parse.js b/lib/cookies/parse.js index aae2750360b..8d60d1cb69b 100644 --- a/lib/cookies/parse.js +++ b/lib/cookies/parse.js @@ -3,7 +3,7 @@ const { maxNameValuePairSize, maxAttributeValueSize } = require('./constants') const { isCTLExcludingHtab } = require('./util') const { collectASequenceOfCodePointsFast } = require('../fetch/dataURL') -const assert = require('assert') +const assert = require('node:assert') /** * @description Parses the field-value attributes of a set-cookie header string. diff --git a/lib/cookies/util.js b/lib/cookies/util.js index 2290329fe8e..203c4bcf37c 100644 --- a/lib/cookies/util.js +++ b/lib/cookies/util.js @@ -1,6 +1,6 @@ 'use strict' -const assert = require('assert') +const assert = require('node:assert') const { kHeadersList } = require('../core/symbols') function isCTLExcludingHtab (value) { diff --git a/lib/core/connect.js b/lib/core/connect.js index 2d2521dcfbd..94b629493de 100644 --- a/lib/core/connect.js +++ b/lib/core/connect.js @@ -1,7 +1,7 @@ 'use strict' -const net = require('net') -const assert = require('assert') +const net = require('node:net') +const assert = require('node:assert') const util = require('./util') const { InvalidArgumentError, ConnectTimeoutError } = require('./errors') @@ -86,7 +86,7 @@ function buildConnector ({ allowH2, maxCachedSessions, socketPath, timeout, ...o let socket if (protocol === 'https:') { if (!tls) { - tls = require('tls') + tls = require('node:tls') } servername = servername || options.servername || util.getServerName(host) || null diff --git a/lib/core/diagnostics.js b/lib/core/diagnostics.js index e76f73a8c3a..e1af3db6112 100644 --- a/lib/core/diagnostics.js +++ b/lib/core/diagnostics.js @@ -1,6 +1,6 @@ 'use strict' -const diagnosticsChannel = require('diagnostics_channel') -const util = require('util') +const diagnosticsChannel = require('node:diagnostics_channel') +const util = require('node:util') const undiciDebugLog = util.debuglog('undici') const fetchDebuglog = util.debuglog('fetch') diff --git a/lib/core/request.js b/lib/core/request.js index 4a61da0e454..7f8a82e6701 100644 --- a/lib/core/request.js +++ b/lib/core/request.js @@ -4,7 +4,7 @@ const { InvalidArgumentError, NotSupportedError } = require('./errors') -const assert = require('assert') +const assert = require('node:assert') const { kHTTP2BuildRequest, kHTTP2CopyHeaders, kHTTP1BuildRequest } = require('./symbols') const util = require('./util') const { channels } = require('./diagnostics.js') diff --git a/lib/core/util.js b/lib/core/util.js index 94a8a04c89e..69fe8956825 100644 --- a/lib/core/util.js +++ b/lib/core/util.js @@ -1,14 +1,14 @@ 'use strict' -const assert = require('assert') +const assert = require('node:assert') const { kDestroyed, kBodyUsed } = require('./symbols') -const { IncomingMessage } = require('http') -const stream = require('stream') -const net = require('net') +const { IncomingMessage } = require('node:http') +const stream = require('node:stream') +const net = require('node:net') const { InvalidArgumentError } = require('./errors') -const { Blob } = require('buffer') -const nodeUtil = require('util') -const { stringify } = require('querystring') +const { Blob } = require('node:buffer') +const nodeUtil = require('node:util') +const { stringify } = require('node:querystring') const { headerNameLowerCasedRecord } = require('./constants') const { tree } = require('./tree') diff --git a/lib/dispatcher.js b/lib/dispatcher.js index 9b809d892d0..71db7e2bb49 100644 --- a/lib/dispatcher.js +++ b/lib/dispatcher.js @@ -1,6 +1,6 @@ 'use strict' -const EventEmitter = require('events') +const EventEmitter = require('node:events') class Dispatcher extends EventEmitter { dispatch () { diff --git a/lib/fetch/body.js b/lib/fetch/body.js index 16914c14c8f..621c5a2d47b 100644 --- a/lib/fetch/body.js +++ b/lib/fetch/body.js @@ -13,9 +13,9 @@ const { const { FormData } = require('./formdata') const { kState } = require('./symbols') const { webidl } = require('./webidl') -const { Blob, File: NativeFile } = require('buffer') +const { Blob, File: NativeFile } = require('node:buffer') const { kBodyUsed, kHeadersList } = require('../core/symbols') -const assert = require('assert') +const assert = require('node:assert') const { isErrored } = require('../core/util') const { isUint8Array, isArrayBuffer } = require('util/types') const { File: UndiciFile } = require('./file') diff --git a/lib/fetch/dataURL.js b/lib/fetch/dataURL.js index d7a638866a3..2b78efdaf27 100644 --- a/lib/fetch/dataURL.js +++ b/lib/fetch/dataURL.js @@ -1,4 +1,4 @@ -const assert = require('assert') +const assert = require('node:assert') const { isomorphicDecode } = require('./util') const encoder = new TextEncoder() diff --git a/lib/fetch/file.js b/lib/fetch/file.js index 397994c0d93..e4230880c92 100644 --- a/lib/fetch/file.js +++ b/lib/fetch/file.js @@ -1,7 +1,7 @@ 'use strict' -const { Blob, File: NativeFile } = require('buffer') -const { types } = require('util') +const { Blob, File: NativeFile } = require('node:buffer') +const { types } = require('node:util') const { kState } = require('./symbols') const { isBlobLike } = require('./util') const { webidl } = require('./webidl') diff --git a/lib/fetch/formdata.js b/lib/fetch/formdata.js index 5975e26c1a0..ea5163f4e37 100644 --- a/lib/fetch/formdata.js +++ b/lib/fetch/formdata.js @@ -4,7 +4,7 @@ const { isBlobLike, toUSVString, makeIterator } = require('./util') const { kState } = require('./symbols') const { File: UndiciFile, FileLike, isFileLike } = require('./file') const { webidl } = require('./webidl') -const { Blob, File: NativeFile } = require('buffer') +const { Blob, File: NativeFile } = require('node:buffer') /** @type {globalThis['File']} */ const File = NativeFile ?? UndiciFile diff --git a/lib/fetch/headers.js b/lib/fetch/headers.js index a905baef499..e1619faf008 100644 --- a/lib/fetch/headers.js +++ b/lib/fetch/headers.js @@ -11,7 +11,7 @@ const { isValidHeaderValue } = require('./util') const { webidl } = require('./webidl') -const assert = require('assert') +const assert = require('node:assert') const kHeadersMap = Symbol('headers map') const kHeadersSortedMap = Symbol('headers map sorted') diff --git a/lib/fetch/index.js b/lib/fetch/index.js index 06fd8a1d589..d14f4f998fd 100644 --- a/lib/fetch/index.js +++ b/lib/fetch/index.js @@ -11,7 +11,7 @@ const { } = require('./response') const { HeadersList } = require('./headers') const { Request, makeRequest } = require('./request') -const zlib = require('zlib') +const zlib = require('node:zlib') const { bytesMatch, makePolicyContainer, @@ -47,7 +47,7 @@ const { createInflate } = require('./util') const { kState } = require('./symbols') -const assert = require('assert') +const assert = require('node:assert') const { safelyExtractBody, extractBody } = require('./body') const { redirectStatusSet, @@ -56,13 +56,13 @@ const { requestBodyHeader, subresourceSet } = require('./constants') -const EE = require('events') -const { Readable, pipeline } = require('stream') +const EE = require('node:events') +const { Readable, pipeline } = require('node:stream') const { addAbortListener, isErrored, isReadable, nodeMajor, nodeMinor, bufferToLowerCasedHeaderName } = require('../core/util') const { dataURLProcessor, serializeAMimeType, parseMIMEType } = require('./dataURL') const { getGlobalDispatcher } = require('../global') const { webidl } = require('./webidl') -const { STATUS_CODES } = require('http') +const { STATUS_CODES } = require('node:http') const GET_OR_HEAD = ['GET', 'HEAD'] /** @type {import('buffer').resolveObjectURL} */ @@ -794,7 +794,7 @@ function schemeFetch (fetchParams) { } case 'blob:': { if (!resolveObjectURL) { - resolveObjectURL = require('buffer').resolveObjectURL + resolveObjectURL = require('node:buffer').resolveObjectURL } // 1. Let blobURLEntry be request’s current URL’s blob URL entry. diff --git a/lib/fetch/request.js b/lib/fetch/request.js index a23e6644c11..998e407e527 100644 --- a/lib/fetch/request.js +++ b/lib/fetch/request.js @@ -29,8 +29,8 @@ const { webidl } = require('./webidl') const { getGlobalOrigin } = require('./global') const { URLSerializer } = require('./dataURL') const { kHeadersList, kConstruct } = require('../core/symbols') -const assert = require('assert') -const { getMaxListeners, setMaxListeners, getEventListeners, defaultMaxListeners } = require('events') +const assert = require('node:assert') +const { getMaxListeners, setMaxListeners, getEventListeners, defaultMaxListeners } = require('node:events') const kAbortController = Symbol('abortController') diff --git a/lib/fetch/response.js b/lib/fetch/response.js index b8fc425891e..3255b78dab7 100644 --- a/lib/fetch/response.js +++ b/lib/fetch/response.js @@ -23,8 +23,8 @@ const { FormData } = require('./formdata') const { getGlobalOrigin } = require('./global') const { URLSerializer } = require('./dataURL') const { kHeadersList, kConstruct } = require('../core/symbols') -const assert = require('assert') -const { types } = require('util') +const assert = require('node:assert') +const { types } = require('node:util') const textEncoder = new TextEncoder('utf-8') diff --git a/lib/fetch/util.js b/lib/fetch/util.js index b179145c825..ebc9b41601b 100644 --- a/lib/fetch/util.js +++ b/lib/fetch/util.js @@ -4,9 +4,9 @@ const { Transform } = require('node:stream') const zlib = require('node:zlib') const { redirectStatusSet, referrerPolicySet: referrerPolicyTokens, badPortsSet } = require('./constants') const { getGlobalOrigin } = require('./global') -const { performance } = require('perf_hooks') +const { performance } = require('node:perf_hooks') const { isBlobLike, toUSVString, ReadableStreamFrom, isValidHTTPToken } = require('../core/util') -const assert = require('assert') +const assert = require('node:assert') const { isUint8Array } = require('util/types') // https://nodejs.org/api/crypto.html#determining-if-crypto-support-is-unavailable @@ -14,7 +14,7 @@ const { isUint8Array } = require('util/types') let crypto try { - crypto = require('crypto') + crypto = require('node:crypto') } catch { } diff --git a/lib/fetch/webidl.js b/lib/fetch/webidl.js index e43cdf6aecc..cb6bcc37db9 100644 --- a/lib/fetch/webidl.js +++ b/lib/fetch/webidl.js @@ -1,6 +1,6 @@ 'use strict' -const { types } = require('util') +const { types } = require('node:util') const { toUSVString } = require('./util') /** @type {import('../../types/webidl').Webidl} */ diff --git a/lib/fileapi/util.js b/lib/fileapi/util.js index a29423d9d14..ce8b10aa2de 100644 --- a/lib/fileapi/util.js +++ b/lib/fileapi/util.js @@ -10,9 +10,9 @@ const { const { ProgressEvent } = require('./progressevent') const { getEncoding } = require('./encoding') const { serializeAMimeType, parseMIMEType } = require('../fetch/dataURL') -const { types } = require('util') +const { types } = require('node:util') const { StringDecoder } = require('string_decoder') -const { btoa } = require('buffer') +const { btoa } = require('node:buffer') /** @type {PropertyDescriptor} */ const staticPropertyDescriptors = { diff --git a/lib/handler/RedirectHandler.js b/lib/handler/RedirectHandler.js index f95ac7e6076..368ef520d76 100644 --- a/lib/handler/RedirectHandler.js +++ b/lib/handler/RedirectHandler.js @@ -2,9 +2,9 @@ const util = require('../core/util') const { kBodyUsed } = require('../core/symbols') -const assert = require('assert') +const assert = require('node:assert') const { InvalidArgumentError } = require('../core/errors') -const EE = require('events') +const EE = require('node:events') const redirectableStatusCodes = [300, 301, 302, 303, 307, 308] diff --git a/lib/handler/RetryHandler.js b/lib/handler/RetryHandler.js index da35d256baa..13eb1005083 100644 --- a/lib/handler/RetryHandler.js +++ b/lib/handler/RetryHandler.js @@ -1,4 +1,4 @@ -const assert = require('assert') +const assert = require('node:assert') const { kRetryHandlerDefaultRetry } = require('../core/symbols') const { RequestRetryError } = require('../core/errors') diff --git a/lib/mock/mock-client.js b/lib/mock/mock-client.js index 5f312159623..193f217501d 100644 --- a/lib/mock/mock-client.js +++ b/lib/mock/mock-client.js @@ -1,6 +1,6 @@ 'use strict' -const { promisify } = require('util') +const { promisify } = require('node:util') const Client = require('../client') const { buildMockDispatch } = require('./mock-utils') const { diff --git a/lib/mock/mock-pool.js b/lib/mock/mock-pool.js index 0a3a7cd35ea..17695e72eba 100644 --- a/lib/mock/mock-pool.js +++ b/lib/mock/mock-pool.js @@ -1,6 +1,6 @@ 'use strict' -const { promisify } = require('util') +const { promisify } = require('node:util') const Pool = require('../pool') const { buildMockDispatch } = require('./mock-utils') const { diff --git a/lib/mock/mock-utils.js b/lib/mock/mock-utils.js index d6b00943564..96282f0ec9d 100644 --- a/lib/mock/mock-utils.js +++ b/lib/mock/mock-utils.js @@ -9,12 +9,12 @@ const { kGetNetConnect } = require('./mock-symbols') const { buildURL, nop } = require('../core/util') -const { STATUS_CODES } = require('http') +const { STATUS_CODES } = require('node:http') const { types: { isPromise } -} = require('util') +} = require('node:util') function matchValue (match, value) { if (typeof match === 'string') { diff --git a/lib/mock/pending-interceptors-formatter.js b/lib/mock/pending-interceptors-formatter.js index 1bc7539fd2e..ba6e4ebce1b 100644 --- a/lib/mock/pending-interceptors-formatter.js +++ b/lib/mock/pending-interceptors-formatter.js @@ -1,7 +1,7 @@ 'use strict' -const { Transform } = require('stream') -const { Console } = require('console') +const { Transform } = require('node:stream') +const { Console } = require('node:console') /** * Gets the output of `console.table(…)` as a string. diff --git a/lib/proxy-agent.js b/lib/proxy-agent.js index c0b5a24bfd1..54b078a7d62 100644 --- a/lib/proxy-agent.js +++ b/lib/proxy-agent.js @@ -1,7 +1,7 @@ 'use strict' const { kProxy, kClose, kDestroy, kInterceptors } = require('./core/symbols') -const { URL } = require('url') +const { URL } = require('node:url') const Agent = require('./agent') const Pool = require('./pool') const DispatcherBase = require('./dispatcher-base') diff --git a/lib/websocket/connection.js b/lib/websocket/connection.js index d8a4f04f637..399c3f52f14 100644 --- a/lib/websocket/connection.js +++ b/lib/websocket/connection.js @@ -19,7 +19,7 @@ const { kHeadersList } = require('../core/symbols') /** @type {import('crypto')} */ let crypto try { - crypto = require('crypto') + crypto = require('node:crypto') } catch { } diff --git a/lib/websocket/events.js b/lib/websocket/events.js index 621a2263b7d..626e8da0583 100644 --- a/lib/websocket/events.js +++ b/lib/websocket/events.js @@ -2,7 +2,7 @@ const { webidl } = require('../fetch/webidl') const { kEnumerableProperty } = require('../core/util') -const { MessagePort } = require('worker_threads') +const { MessagePort } = require('node:worker_threads') /** * @see https://html.spec.whatwg.org/multipage/comms.html#messageevent diff --git a/lib/websocket/frame.js b/lib/websocket/frame.js index d867ad118b2..ee3087bdf70 100644 --- a/lib/websocket/frame.js +++ b/lib/websocket/frame.js @@ -5,7 +5,7 @@ const { maxUnsigned16Bit } = require('./constants') /** @type {import('crypto')} */ let crypto try { - crypto = require('crypto') + crypto = require('node:crypto') } catch { } diff --git a/lib/websocket/receiver.js b/lib/websocket/receiver.js index 512ef42a06b..b8b63ceb9d8 100644 --- a/lib/websocket/receiver.js +++ b/lib/websocket/receiver.js @@ -1,6 +1,6 @@ 'use strict' -const { Writable } = require('stream') +const { Writable } = require('node:stream') const { parserStates, opcodes, states, emptyBuffer } = require('./constants') const { kReadyState, kSentClose, kResponse, kReceivedClose } = require('./symbols') const { channels } = require('../core/diagnostics') diff --git a/lib/websocket/websocket.js b/lib/websocket/websocket.js index 77a12396dcd..6cbd01666ef 100644 --- a/lib/websocket/websocket.js +++ b/lib/websocket/websocket.js @@ -19,7 +19,7 @@ const { WebsocketFrameSend } = require('./frame') const { ByteParser } = require('./receiver') const { kEnumerableProperty, isBlobLike } = require('../core/util') const { getGlobalDispatcher } = require('../global') -const { types } = require('util') +const { types } = require('node:util') let experimentalWarned = false diff --git a/test/client-connect.js b/test/client-connect.js index 4131c6e0a13..587361f9ef0 100644 --- a/test/client-connect.js +++ b/test/client-connect.js @@ -2,8 +2,8 @@ const { test } = require('tap') const { Client, errors } = require('..') -const http = require('http') -const EE = require('events') +const http = require('node:http') +const EE = require('node:events') const { kBusy } = require('../lib/core/symbols') // TODO: move to test/node-test/client-connect.js diff --git a/test/client-errors.js b/test/client-errors.js index 27cc52ba562..21732ac075a 100644 --- a/test/client-errors.js +++ b/test/client-errors.js @@ -2,7 +2,7 @@ const { test } = require('tap') const { Client } = require('..') -const net = require('net') +const net = require('node:net') // TODO: move to test/node-test/client-connect.js test('parser error', (t) => { diff --git a/test/client-head-reset-override.js b/test/client-head-reset-override.js index a7d79e25d75..9639e94860d 100644 --- a/test/client-head-reset-override.js +++ b/test/client-head-reset-override.js @@ -1,6 +1,6 @@ 'use strict' -const { createServer } = require('http') +const { createServer } = require('node:http') const { test } = require('tap') const { Client } = require('..') diff --git a/test/client-idempotent-body.js b/test/client-idempotent-body.js index 99e53713d00..0575b6b8ebd 100644 --- a/test/client-idempotent-body.js +++ b/test/client-idempotent-body.js @@ -2,7 +2,7 @@ const { test } = require('tap') const { Client } = require('..') -const { createServer } = require('http') +const { createServer } = require('node:http') test('idempotent retry', (t) => { t.plan(11) diff --git a/test/client-keep-alive.js b/test/client-keep-alive.js index 393807be9db..924874232d7 100644 --- a/test/client-keep-alive.js +++ b/test/client-keep-alive.js @@ -4,8 +4,8 @@ const { test } = require('tap') const { Client } = require('..') const timers = require('../lib/timers') const { kConnect } = require('../lib/core/symbols') -const { createServer } = require('net') -const http = require('http') +const { createServer } = require('node:net') +const http = require('node:http') const FakeTimers = require('@sinonjs/fake-timers') test('keep-alive header', (t) => { diff --git a/test/client-pipeline.js b/test/client-pipeline.js index 75b59e83422..300e42c7eb2 100644 --- a/test/client-pipeline.js +++ b/test/client-pipeline.js @@ -2,15 +2,15 @@ const { test } = require('tap') const { Client, errors } = require('..') -const EE = require('events') -const { createServer } = require('http') +const EE = require('node:events') +const { createServer } = require('node:http') const { pipeline, Readable, Transform, Writable, PassThrough -} = require('stream') +} = require('node:stream') test('pipeline get', (t) => { t.plan(17) diff --git a/test/client-pipelining.js b/test/client-pipelining.js index 8cd21feed10..38a99f54c5b 100644 --- a/test/client-pipelining.js +++ b/test/client-pipelining.js @@ -2,10 +2,10 @@ const { test } = require('tap') const { Client } = require('..') -const { createServer } = require('http') -const { finished, Readable } = require('stream') +const { createServer } = require('node:http') +const { finished, Readable } = require('node:stream') const { kConnect } = require('../lib/core/symbols') -const EE = require('events') +const EE = require('node:events') const { kBusy, kRunning, kSize } = require('../lib/core/symbols') const { maybeWrapStream, consts } = require('./utils/async-iterators') diff --git a/test/client-post.js b/test/client-post.js index 363b43ca34d..fc696c951a5 100644 --- a/test/client-post.js +++ b/test/client-post.js @@ -2,8 +2,8 @@ const { test } = require('tap') const { Client } = require('..') -const { createServer } = require('http') -const { Blob } = require('buffer') +const { createServer } = require('node:http') +const { Blob } = require('node:buffer') test('request post blob', { skip: !Blob }, (t) => { t.plan(4) diff --git a/test/client-reconnect.js b/test/client-reconnect.js index ae1a206de63..85f76ef5f62 100644 --- a/test/client-reconnect.js +++ b/test/client-reconnect.js @@ -2,7 +2,7 @@ const { test } = require('tap') const { Client } = require('..') -const { createServer } = require('http') +const { createServer } = require('node:http') const FakeTimers = require('@sinonjs/fake-timers') const timers = require('../lib/timers') diff --git a/test/client-request.js b/test/client-request.js index 3f74ce8cc70..ebcc0c2e96f 100644 --- a/test/client-request.js +++ b/test/client-request.js @@ -4,12 +4,12 @@ const { test } = require('tap') const { Client, errors } = require('..') -const { createServer } = require('http') -const EE = require('events') +const { createServer } = require('node:http') +const EE = require('node:events') const { kConnect } = require('../lib/core/symbols') -const { Readable } = require('stream') -const net = require('net') -const { promisify } = require('util') +const { Readable } = require('node:stream') +const net = require('node:net') +const { promisify } = require('node:util') const { NotSupportedError } = require('../lib/core/errors') const { parseFormDataString } = require('./utils/formdata') @@ -719,7 +719,7 @@ test('request text2', (t) => { test('request with FormData body', (t) => { const { FormData } = require('../') - const { Blob } = require('buffer') + const { Blob } = require('node:buffer') const fd = new FormData() fd.set('key', 'value') diff --git a/test/client-stream.js b/test/client-stream.js index a230c443b67..7732187f159 100644 --- a/test/client-stream.js +++ b/test/client-stream.js @@ -2,9 +2,9 @@ const { test } = require('tap') const { Client, errors } = require('..') -const { createServer } = require('http') -const { PassThrough, Writable, Readable } = require('stream') -const EE = require('events') +const { createServer } = require('node:http') +const { PassThrough, Writable, Readable } = require('node:stream') +const EE = require('node:events') test('stream get', (t) => { t.plan(9) diff --git a/test/client-timeout.js b/test/client-timeout.js index 5f1686a0251..e02c46ceff3 100644 --- a/test/client-timeout.js +++ b/test/client-timeout.js @@ -2,8 +2,8 @@ const { test } = require('tap') const { Client, errors } = require('..') -const { createServer } = require('http') -const { Readable } = require('stream') +const { createServer } = require('node:http') +const { Readable } = require('node:stream') const FakeTimers = require('@sinonjs/fake-timers') const timers = require('../lib/timers') diff --git a/test/client-unref.js b/test/client-unref.js index c7e3a5db734..f46376f9c46 100644 --- a/test/client-unref.js +++ b/test/client-unref.js @@ -1,10 +1,10 @@ 'use strict' -const { Worker, isMainThread, workerData } = require('worker_threads') +const { Worker, isMainThread, workerData } = require('node:worker_threads') if (isMainThread) { const tap = require('tap') - const { createServer } = require('http') + const { createServer } = require('node:http') tap.test('client automatically closes itself when idle', t => { t.plan(1) diff --git a/test/client-upgrade.js b/test/client-upgrade.js index 4ccbcce01ef..80aa7314b30 100644 --- a/test/client-upgrade.js +++ b/test/client-upgrade.js @@ -2,9 +2,9 @@ const { test } = require('tap') const { Client, errors } = require('..') -const net = require('net') -const http = require('http') -const EE = require('events') +const net = require('node:net') +const http = require('node:http') +const EE = require('node:events') const { kBusy } = require('../lib/core/symbols') test('basic upgrade', (t) => { diff --git a/test/client-write-max-listeners.js b/test/client-write-max-listeners.js index 118cdaad0b5..c511fb4fb68 100644 --- a/test/client-write-max-listeners.js +++ b/test/client-write-max-listeners.js @@ -2,8 +2,8 @@ const { test } = require('tap') const { Client } = require('..') -const { createServer } = require('http') -const { Readable } = require('stream') +const { createServer } = require('node:http') +const { Readable } = require('node:stream') test('socket close listener does not leak', (t) => { t.plan(32) diff --git a/test/client.js b/test/client.js index 92315d647e5..5aa031f6907 100644 --- a/test/client.js +++ b/test/client.js @@ -1,17 +1,17 @@ 'use strict' -const { readFileSync, createReadStream } = require('fs') -const { createServer } = require('http') -const { Readable } = require('stream') +const { readFileSync, createReadStream } = require('node:fs') +const { createServer } = require('node:http') +const { Readable } = require('node:stream') const { test } = require('tap') const { Client, errors } = require('..') const { kSocket } = require('../lib/core/symbols') const { wrapWithAsyncIterable } = require('./utils/async-iterators') -const EE = require('events') +const EE = require('node:events') const { kUrl, kSize, kConnect, kBusy, kConnected, kRunning } = require('../lib/core/symbols') const hasIPv6 = (() => { - const iFaces = require('os').networkInterfaces() + const iFaces = require('node:os').networkInterfaces() const re = process.platform === 'win32' ? /Loopback Pseudo-Interface/ : /lo/ return Object.keys(iFaces).some( (name) => re.test(name) && iFaces[name].some(({ family }) => family === 6) diff --git a/test/close-and-destroy.js b/test/close-and-destroy.js index bd50ebb8e99..6675e1d2cd0 100644 --- a/test/close-and-destroy.js +++ b/test/close-and-destroy.js @@ -2,7 +2,7 @@ const { test } = require('tap') const { Client, errors } = require('..') -const { createServer } = require('http') +const { createServer } = require('node:http') const { kSocket, kSize } = require('../lib/core/symbols') test('close waits for queued requests to finish', (t) => { diff --git a/test/connect-abort.js b/test/connect-abort.js index 6eb36243866..91ed1b2a258 100644 --- a/test/connect-abort.js +++ b/test/connect-abort.js @@ -2,7 +2,7 @@ const { test } = require('tap') const { Client } = require('..') -const { PassThrough } = require('stream') +const { PassThrough } = require('node:stream') test(t => { t.plan(2) diff --git a/test/connect-errconnect.js b/test/connect-errconnect.js index defeda32454..885d6ddb19c 100644 --- a/test/connect-errconnect.js +++ b/test/connect-errconnect.js @@ -2,7 +2,7 @@ const { test } = require('tap') const { Client } = require('..') -const net = require('net') +const net = require('node:net') test('connect-connectionError', t => { t.plan(2) diff --git a/test/connect-timeout.js b/test/connect-timeout.js index d998321da82..9c001a35d97 100644 --- a/test/connect-timeout.js +++ b/test/connect-timeout.js @@ -2,7 +2,7 @@ const { test } = require('tap') const { Client, Pool, errors } = require('..') -const net = require('net') +const net = require('node:net') const sleep = ms => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, Number(ms)) test('prioritize socket errors over timeouts', (t) => { diff --git a/test/content-length.js b/test/content-length.js index 9ce74051d8b..0257e4d62a4 100644 --- a/test/content-length.js +++ b/test/content-length.js @@ -2,8 +2,8 @@ const { test } = require('tap') const { Client, errors } = require('..') -const { createServer } = require('http') -const { Readable } = require('stream') +const { createServer } = require('node:http') +const { Readable } = require('node:stream') const { maybeWrapStream, consts } = require('./utils/async-iterators') test('request invalid content-length', (t) => { diff --git a/test/examples.js b/test/examples.js index 9b814820cb8..7096970662f 100644 --- a/test/examples.js +++ b/test/examples.js @@ -1,6 +1,6 @@ 'use strict' -const { createServer } = require('http') +const { createServer } = require('node:http') const { test } = require('tap') const examples = require('../examples/request.js') diff --git a/test/fetch/407-statuscode-window-null.js b/test/fetch/407-statuscode-window-null.js index 8304570976b..e03042e4c09 100644 --- a/test/fetch/407-statuscode-window-null.js +++ b/test/fetch/407-statuscode-window-null.js @@ -1,8 +1,8 @@ 'use strict' const { fetch } = require('../..') -const { createServer } = require('http') -const { once } = require('events') +const { createServer } = require('node:http') +const { once } = require('node:events') const { test } = require('node:test') const assert = require('node:assert') diff --git a/test/fetch/abort.js b/test/fetch/abort.js index f2c98e46698..018c9a10b68 100644 --- a/test/fetch/abort.js +++ b/test/fetch/abort.js @@ -4,8 +4,8 @@ const { test } = require('node:test') const assert = require('node:assert') const { tspl } = require('@matteo.collina/tspl') const { fetch } = require('../..') -const { createServer } = require('http') -const { once } = require('events') +const { createServer } = require('node:http') +const { once } = require('node:events') const { closeServerAsPromise } = require('../utils/node-http') diff --git a/test/fetch/abort2.js b/test/fetch/abort2.js index 6a1e243cdec..fec300b43df 100644 --- a/test/fetch/abort2.js +++ b/test/fetch/abort2.js @@ -3,8 +3,8 @@ const { test } = require('node:test') const assert = require('node:assert') const { fetch } = require('../..') -const { createServer } = require('http') -const { once } = require('events') +const { createServer } = require('node:http') +const { once } = require('node:events') const { closeServerAsPromise } = require('../utils/node-http') diff --git a/test/fetch/blob-uri.js b/test/fetch/blob-uri.js index 9ba2c5f30ca..5d3d3f4dfd3 100644 --- a/test/fetch/blob-uri.js +++ b/test/fetch/blob-uri.js @@ -3,7 +3,7 @@ const { test } = require('node:test') const assert = require('node:assert') const { fetch } = require('../..') -const { Blob } = require('buffer') +const { Blob } = require('node:buffer') test('fetching blob: uris', async (t) => { const blobContents = 'hello world' diff --git a/test/fetch/client-fetch.js b/test/fetch/client-fetch.js index 075bda7ec05..e0fcb97eca1 100644 --- a/test/fetch/client-fetch.js +++ b/test/fetch/client-fetch.js @@ -5,15 +5,15 @@ const { test, after } = require('node:test') const assert = require('node:assert') const { tspl } = require('@matteo.collina/tspl') -const { createServer } = require('http') -const { Blob } = require('buffer') +const { createServer } = require('node:http') +const { Blob } = require('node:buffer') const { fetch, Response, Request, FormData, File } = require('../..') const { Client, setGlobalDispatcher, Agent } = require('../..') const nodeFetch = require('../../index-fetch') -const { once } = require('events') -const { gzipSync } = require('zlib') -const { promisify } = require('util') -const { randomFillSync, createHash } = require('crypto') +const { once } = require('node:events') +const { gzipSync } = require('node:zlib') +const { promisify } = require('node:util') +const { randomFillSync, createHash } = require('node:crypto') const { closeServerAsPromise } = require('../utils/node-http') diff --git a/test/fetch/content-length.js b/test/fetch/content-length.js index 384ba2491d6..637ff0b800e 100644 --- a/test/fetch/content-length.js +++ b/test/fetch/content-length.js @@ -2,9 +2,9 @@ const { test } = require('node:test') const assert = require('node:assert') -const { createServer } = require('http') -const { once } = require('events') -const { Blob } = require('buffer') +const { createServer } = require('node:http') +const { once } = require('node:events') +const { Blob } = require('node:buffer') const { fetch, FormData } = require('../..') const { closeServerAsPromise } = require('../utils/node-http') diff --git a/test/fetch/cookies.js b/test/fetch/cookies.js index 900c2d3a22b..c34f3dc921a 100644 --- a/test/fetch/cookies.js +++ b/test/fetch/cookies.js @@ -1,7 +1,7 @@ 'use strict' -const { once } = require('events') -const { createServer } = require('http') +const { once } = require('node:events') +const { createServer } = require('node:http') const { test } = require('node:test') const assert = require('node:assert') const { tspl } = require('@matteo.collina/tspl') diff --git a/test/fetch/encoding.js b/test/fetch/encoding.js index 5e8c3149dc9..3986e03e505 100644 --- a/test/fetch/encoding.js +++ b/test/fetch/encoding.js @@ -2,10 +2,10 @@ const { test } = require('node:test') const assert = require('node:assert') -const { createServer } = require('http') -const { once } = require('events') +const { createServer } = require('node:http') +const { once } = require('node:events') const { fetch } = require('../..') -const { createBrotliCompress, createGzip, createDeflate } = require('zlib') +const { createBrotliCompress, createGzip, createDeflate } = require('node:zlib') const { closeServerAsPromise } = require('../utils/node-http') test('content-encoding header is case-iNsENsITIve', async (t) => { diff --git a/test/fetch/fetch-leak.js b/test/fetch/fetch-leak.js index 21838d4bde6..a0b2995025d 100644 --- a/test/fetch/fetch-leak.js +++ b/test/fetch/fetch-leak.js @@ -4,7 +4,7 @@ const { test } = require('node:test') const assert = require('node:assert') const { tspl } = require('@matteo.collina/tspl') const { fetch } = require('../..') -const { createServer } = require('http') +const { createServer } = require('node:http') const { closeServerAsPromise } = require('../utils/node-http') test('do not leak', (t, done) => { diff --git a/test/fetch/fetch-timeouts.js b/test/fetch/fetch-timeouts.js index 71a2f36897f..93792871cb1 100644 --- a/test/fetch/fetch-timeouts.js +++ b/test/fetch/fetch-timeouts.js @@ -5,7 +5,7 @@ const { tspl } = require('@matteo.collina/tspl') const { fetch, Agent } = require('../..') const timers = require('../../lib/timers') -const { createServer } = require('http') +const { createServer } = require('node:http') const FakeTimers = require('@sinonjs/fake-timers') const { closeServerAsPromise } = require('../utils/node-http') diff --git a/test/fetch/file.js b/test/fetch/file.js index 877ce190469..44149653c12 100644 --- a/test/fetch/file.js +++ b/test/fetch/file.js @@ -1,6 +1,6 @@ 'use strict' -const { Blob } = require('buffer') +const { Blob } = require('node:buffer') const { test } = require('node:test') const assert = require('node:assert') const { tspl } = require('@matteo.collina/tspl') diff --git a/test/fetch/formdata.js b/test/fetch/formdata.js index 157b7a77868..3558001f10a 100644 --- a/test/fetch/formdata.js +++ b/test/fetch/formdata.js @@ -5,7 +5,7 @@ const assert = require('node:assert') const { tspl } = require('@matteo.collina/tspl') const { FormData, File, Response } = require('../../') const { Blob: ThirdPartyBlob } = require('formdata-node') -const { Blob } = require('buffer') +const { Blob } = require('node:buffer') const { isFormDataLike } = require('../../lib/core/util') const ThirdPartyFormDataInvalid = require('form-data') diff --git a/test/fetch/headers.js b/test/fetch/headers.js index 3954ae11111..b61d8b612d2 100644 --- a/test/fetch/headers.js +++ b/test/fetch/headers.js @@ -5,9 +5,9 @@ const assert = require('node:assert') const { tspl } = require('@matteo.collina/tspl') const { Headers, fill } = require('../../lib/fetch/headers') const { kGuard } = require('../../lib/fetch/symbols') -const { once } = require('events') +const { once } = require('node:events') const { fetch } = require('../..') -const { createServer } = require('http') +const { createServer } = require('node:http') const { closeServerAsPromise } = require('../utils/node-http') test('Headers initialization', async (t) => { diff --git a/test/fetch/integrity.js b/test/fetch/integrity.js index e401a06687e..f3bc27e4dc5 100644 --- a/test/fetch/integrity.js +++ b/test/fetch/integrity.js @@ -2,11 +2,11 @@ const { test } = require('node:test') const assert = require('node:assert') -const { createServer } = require('http') -const { createHash, getHashes } = require('crypto') -const { gzipSync } = require('zlib') +const { createServer } = require('node:http') +const { createHash, getHashes } = require('node:crypto') +const { gzipSync } = require('node:zlib') const { fetch, setGlobalDispatcher, Agent } = require('../..') -const { once } = require('events') +const { once } = require('node:events') const { closeServerAsPromise } = require('../utils/node-http') const supportedHashes = getHashes() diff --git a/test/fetch/issue-2009.js b/test/fetch/issue-2009.js index 13d25b6444a..d77b60b6334 100644 --- a/test/fetch/issue-2009.js +++ b/test/fetch/issue-2009.js @@ -3,8 +3,8 @@ const { test } = require('node:test') const { tspl } = require('@matteo.collina/tspl') const { fetch } = require('../..') -const { createServer } = require('http') -const { once } = require('events') +const { createServer } = require('node:http') +const { once } = require('node:events') const { closeServerAsPromise } = require('../utils/node-http') test('issue 2009', async (t) => { diff --git a/test/fetch/issue-2021.js b/test/fetch/issue-2021.js index be8941951cb..5b949e507de 100644 --- a/test/fetch/issue-2021.js +++ b/test/fetch/issue-2021.js @@ -2,8 +2,8 @@ const { test } = require('node:test') const assert = require('node:assert') -const { once } = require('events') -const { createServer } = require('http') +const { once } = require('node:events') +const { createServer } = require('node:http') const { fetch } = require('../..') const { closeServerAsPromise } = require('../utils/node-http') diff --git a/test/fetch/issue-2171.js b/test/fetch/issue-2171.js index cb6350f6aaa..82577f9494c 100644 --- a/test/fetch/issue-2171.js +++ b/test/fetch/issue-2171.js @@ -1,8 +1,8 @@ 'use strict' const { fetch } = require('../..') -const { once } = require('events') -const { createServer } = require('http') +const { once } = require('node:events') +const { createServer } = require('node:http') const { test } = require('node:test') const assert = require('node:assert') const { closeServerAsPromise } = require('../utils/node-http') diff --git a/test/fetch/issue-2318.js b/test/fetch/issue-2318.js index 74f1f5578f8..273e2b9a74c 100644 --- a/test/fetch/issue-2318.js +++ b/test/fetch/issue-2318.js @@ -2,8 +2,8 @@ const { test } = require('node:test') const { tspl } = require('@matteo.collina/tspl') -const { once } = require('events') -const { createServer } = require('http') +const { once } = require('node:events') +const { createServer } = require('node:http') const { fetch } = require('../..') const { closeServerAsPromise } = require('../utils/node-http') diff --git a/test/fetch/issue-node-46525.js b/test/fetch/issue-node-46525.js index 62f910f219f..b35eeb2a590 100644 --- a/test/fetch/issue-node-46525.js +++ b/test/fetch/issue-node-46525.js @@ -1,7 +1,7 @@ 'use strict' -const { once } = require('events') -const { createServer } = require('http') +const { once } = require('node:events') +const { createServer } = require('node:http') const { test } = require('node:test') const { fetch } = require('../..') diff --git a/test/fetch/jsdom-abortcontroller-1910-1464495619.js b/test/fetch/jsdom-abortcontroller-1910-1464495619.js index 15503e7ec5c..b59ef9f95ca 100644 --- a/test/fetch/jsdom-abortcontroller-1910-1464495619.js +++ b/test/fetch/jsdom-abortcontroller-1910-1464495619.js @@ -2,8 +2,8 @@ const { test } = require('node:test') const assert = require('node:assert') -const { createServer } = require('http') -const { once } = require('events') +const { createServer } = require('node:http') +const { once } = require('node:events') const { fetch } = require('../..') const { JSDOM } = require('jsdom') diff --git a/test/fetch/redirect-cross-origin-header.js b/test/fetch/redirect-cross-origin-header.js index 244dbf61b51..5c1d91c9924 100644 --- a/test/fetch/redirect-cross-origin-header.js +++ b/test/fetch/redirect-cross-origin-header.js @@ -2,8 +2,8 @@ const { test } = require('node:test') const { tspl } = require('@matteo.collina/tspl') -const { createServer } = require('http') -const { once } = require('events') +const { createServer } = require('node:http') +const { once } = require('node:events') const { fetch } = require('../..') test('Cross-origin redirects clear forbidden headers', async (t) => { diff --git a/test/fetch/redirect.js b/test/fetch/redirect.js index ebfd458199d..a9533bcc327 100644 --- a/test/fetch/redirect.js +++ b/test/fetch/redirect.js @@ -2,8 +2,8 @@ const { test } = require('node:test') const assert = require('node:assert') -const { createServer } = require('http') -const { once } = require('events') +const { createServer } = require('node:http') +const { once } = require('node:events') const { fetch } = require('../..') const { closeServerAsPromise } = require('../utils/node-http') diff --git a/test/fetch/relative-url.js b/test/fetch/relative-url.js index 9d2480281be..2a57e15c5e5 100644 --- a/test/fetch/relative-url.js +++ b/test/fetch/relative-url.js @@ -2,8 +2,8 @@ const { test, afterEach } = require('node:test') const assert = require('node:assert') -const { createServer } = require('http') -const { once } = require('events') +const { createServer } = require('node:http') +const { once } = require('node:events') const { getGlobalOrigin, setGlobalOrigin, diff --git a/test/fetch/resource-timing.js b/test/fetch/resource-timing.js index f561b723fcc..7617ff06328 100644 --- a/test/fetch/resource-timing.js +++ b/test/fetch/resource-timing.js @@ -2,7 +2,7 @@ const { test } = require('node:test') const { tspl } = require('@matteo.collina/tspl') -const { createServer } = require('http') +const { createServer } = require('node:http') const { nodeMajor, nodeMinor } = require('../../lib/core/util') const { fetch } = require('../..') const { closeServerAsPromise } = require('../utils/node-http') @@ -10,7 +10,7 @@ const { closeServerAsPromise } = require('../utils/node-http') const { PerformanceObserver, performance -} = require('perf_hooks') +} = require('node:perf_hooks') const skip = nodeMajor === 18 && nodeMinor < 2 diff --git a/test/fetch/response-json.js b/test/fetch/response-json.js index 618111b8510..7dc6ad20c37 100644 --- a/test/fetch/response-json.js +++ b/test/fetch/response-json.js @@ -1,7 +1,7 @@ 'use strict' const { test } = require('node:test') -const assert = require('assert') +const assert = require('node:assert') const { Response } = require('../../') // https://github.com/web-platform-tests/wpt/pull/32825/ diff --git a/test/fetch/response.js b/test/fetch/response.js index 68f76fbe045..cfd4ddb6268 100644 --- a/test/fetch/response.js +++ b/test/fetch/response.js @@ -1,7 +1,7 @@ 'use strict' const { test } = require('node:test') -const assert = require('assert') +const assert = require('node:assert') const { tspl } = require('@matteo.collina/tspl') const { Response, diff --git a/test/fetch/user-agent.js b/test/fetch/user-agent.js index 1d638d0a3e7..da8936c8cff 100644 --- a/test/fetch/user-agent.js +++ b/test/fetch/user-agent.js @@ -1,9 +1,9 @@ 'use strict' const { test } = require('node:test') -const assert = require('assert') -const events = require('events') -const http = require('http') +const assert = require('node:assert') +const events = require('node:events') +const http = require('node:http') const undici = require('../../') const { closeServerAsPromise } = require('../utils/node-http') diff --git a/test/fetch/util.js b/test/fetch/util.js index 0330c7d8eed..eb245486f4d 100644 --- a/test/fetch/util.js +++ b/test/fetch/util.js @@ -1,11 +1,11 @@ 'use strict' const { test } = require('node:test') -const assert = require('assert') +const assert = require('node:assert') const { tspl } = require('@matteo.collina/tspl') const util = require('../../lib/fetch/util') const { HeadersList } = require('../../lib/fetch/headers') -const { createHash } = require('crypto') +const { createHash } = require('node:crypto') test('responseURL', (t) => { const { ok } = tspl(t, { plan: 2 }) diff --git a/test/fixtures/fetch.js b/test/fixtures/fetch.js index ae4934a4e58..e6792ed1dbd 100644 --- a/test/fixtures/fetch.js +++ b/test/fixtures/fetch.js @@ -1,4 +1,4 @@ -const { createServer } = require('http') +const { createServer } = require('node:http') const { fetch } = require('../..') const server = createServer((_req, res) => { diff --git a/test/fixtures/undici.js b/test/fixtures/undici.js index 8c6d5aac1d1..6ce69aa6785 100644 --- a/test/fixtures/undici.js +++ b/test/fixtures/undici.js @@ -1,4 +1,4 @@ -const { createServer } = require('http') +const { createServer } = require('node:http') const { request } = require('../..') const server = createServer((_req, res) => { diff --git a/test/fuzzing/fuzz.js b/test/fuzzing/fuzz.js index c2681783741..0d938496309 100644 --- a/test/fuzzing/fuzz.js +++ b/test/fuzzing/fuzz.js @@ -1,8 +1,8 @@ 'use strict' -const net = require('net') +const net = require('node:net') const fs = require('fs/promises') -const path = require('path') +const path = require('node:path') const serverFuzzFnMap = require('./server') const clientFuzzFnMap = require('./client') diff --git a/test/gc.js b/test/gc.js index c1ceecf88ab..ab3b0e83dbf 100644 --- a/test/gc.js +++ b/test/gc.js @@ -2,7 +2,7 @@ /* global WeakRef, FinalizationRegistry */ const { test } = require('tap') -const { createServer } = require('net') +const { createServer } = require('node:net') const { Client, Pool } = require('..') const SKIP = typeof WeakRef === 'undefined' || typeof FinalizationRegistry === 'undefined' diff --git a/test/get-head-body.js b/test/get-head-body.js index 3e86b13bfd3..9b587980224 100644 --- a/test/get-head-body.js +++ b/test/get-head-body.js @@ -2,8 +2,8 @@ const { test } = require('tap') const { Client } = require('..') -const { createServer } = require('http') -const { Readable } = require('stream') +const { createServer } = require('node:http') +const { Readable } = require('node:stream') const { kConnect } = require('../lib/core/symbols') const { kBusy } = require('../lib/core/symbols') const { wrapWithAsyncIterable } = require('./utils/async-iterators') diff --git a/test/headers-as-array.js b/test/headers-as-array.js index fd8bb5dbf5b..315d55b4b64 100644 --- a/test/headers-as-array.js +++ b/test/headers-as-array.js @@ -2,7 +2,7 @@ const { test } = require('tap') const { Client, errors } = require('..') -const { createServer } = require('http') +const { createServer } = require('node:http') test('handle headers as array', (t) => { t.plan(1) diff --git a/test/headers-crlf.js b/test/headers-crlf.js index b24fd391491..d41e924aca1 100644 --- a/test/headers-crlf.js +++ b/test/headers-crlf.js @@ -2,7 +2,7 @@ const { test } = require('tap') const { Client } = require('..') -const { createServer } = require('http') +const { createServer } = require('node:http') test('CRLF Injection in Nodejs ‘undici’ via host', (t) => { t.plan(1) diff --git a/test/http-100.js b/test/http-100.js index 1662a8d6432..add1273d9c0 100644 --- a/test/http-100.js +++ b/test/http-100.js @@ -2,8 +2,8 @@ const { test } = require('tap') const { Client } = require('..') -const { createServer } = require('http') -const net = require('net') +const { createServer } = require('node:http') +const net = require('node:net') test('ignore informational response', (t) => { t.plan(2) diff --git a/test/http-req-destroy.js b/test/http-req-destroy.js index 29ec98e1a9c..d0d83b6d848 100644 --- a/test/http-req-destroy.js +++ b/test/http-req-destroy.js @@ -2,8 +2,8 @@ const { test } = require('tap') const undici = require('..') -const { createServer } = require('http') -const { Readable } = require('stream') +const { createServer } = require('node:http') +const { Readable } = require('node:stream') const { maybeWrapStream, consts } = require('./utils/async-iterators') function doNotKillReqSocket (bodyType) { diff --git a/test/https.js b/test/https.js index 1ba492c0e33..5d9ab3d8e22 100644 --- a/test/https.js +++ b/test/https.js @@ -2,7 +2,7 @@ const { test } = require('tap') const { Client } = require('..') -const { createServer } = require('https') +const { createServer } = require('node:https') const pem = require('https-pem') test('https get with tls opts', (t) => { diff --git a/test/inflight-and-close.js b/test/inflight-and-close.js index 49fbb10f7fc..d1930ff1bed 100644 --- a/test/inflight-and-close.js +++ b/test/inflight-and-close.js @@ -2,7 +2,7 @@ const t = require('tap') const { request } = require('..') -const http = require('http') +const http = require('node:http') const server = http.createServer((req, res) => { res.writeHead(200) diff --git a/test/issue-2065.js b/test/issue-2065.js index 9cc015b9824..5080353a584 100644 --- a/test/issue-2065.js +++ b/test/issue-2065.js @@ -1,9 +1,9 @@ 'use strict' const { test } = require('tap') -const { createServer } = require('http') -const { once } = require('events') -const { createReadStream } = require('fs') +const { createServer } = require('node:http') +const { once } = require('node:events') +const { createReadStream } = require('node:fs') const { File, FormData, request } = require('..') test('undici.request with a FormData body should set content-length header', async (t) => { diff --git a/test/issue-2349.js b/test/issue-2349.js index d6e0dcb2020..fa308227849 100644 --- a/test/issue-2349.js +++ b/test/issue-2349.js @@ -2,7 +2,7 @@ const { test } = require('node:test') const { rejects } = require('node:assert') -const { Writable } = require('stream') +const { Writable } = require('node:stream') const { MockAgent, stream } = require('..') test('stream() does not fail after request has been aborted', () => { diff --git a/test/issue-2590.js b/test/issue-2590.js index 4f5b186dfd3..cd4913c642f 100644 --- a/test/issue-2590.js +++ b/test/issue-2590.js @@ -2,8 +2,8 @@ const { test } = require('tap') const { request } = require('..') -const { createServer } = require('http') -const { once } = require('events') +const { createServer } = require('node:http') +const { once } = require('node:events') test('aborting request with custom reason', async (t) => { const server = createServer(() => {}).listen(0) diff --git a/test/issue-803.js b/test/issue-803.js index 70f64cce773..35975103967 100644 --- a/test/issue-803.js +++ b/test/issue-803.js @@ -2,8 +2,8 @@ const { test } = require('tap') const { Client } = require('..') -const { createServer } = require('http') -const EE = require('events') +const { createServer } = require('node:http') +const EE = require('node:events') test('https://github.com/nodejs/undici/issues/803', (t) => { t.plan(2) diff --git a/test/issue-810.js b/test/issue-810.js index 226a5aaacdb..ba4a35234e7 100644 --- a/test/issue-810.js +++ b/test/issue-810.js @@ -2,7 +2,7 @@ const { test } = require('tap') const { Client, errors } = require('..') -const net = require('net') +const net = require('node:net') test('https://github.com/mcollina/undici/issues/810', (t) => { t.plan(3) diff --git a/test/jest/instanceof-error.test.js b/test/jest/instanceof-error.test.js index 2fa71565172..363ec7013e8 100644 --- a/test/jest/instanceof-error.test.js +++ b/test/jest/instanceof-error.test.js @@ -1,7 +1,7 @@ 'use strict' -const { createServer } = require('http') -const { once } = require('events') +const { createServer } = require('node:http') +const { once } = require('node:events') /* global expect, it, jest, AbortController */ diff --git a/test/jest/interceptor.test.js b/test/jest/interceptor.test.js index 73d70b7c9cd..9caa0758936 100644 --- a/test/jest/interceptor.test.js +++ b/test/jest/interceptor.test.js @@ -1,6 +1,6 @@ 'use strict' -const { createServer } = require('http') +const { createServer } = require('node:http') const { Agent, request } = require('../../index') const DecoratorHandler = require('../../lib/handler/DecoratorHandler') /* global expect */ diff --git a/test/jest/test.js b/test/jest/test.js index 079a41ff195..4be7556e27e 100644 --- a/test/jest/test.js +++ b/test/jest/test.js @@ -1,7 +1,7 @@ 'use strict' const { Client } = require('../..') -const { createServer } = require('http') +const { createServer } = require('node:http') /* global test, expect */ test('should work in jest', async () => { diff --git a/test/max-headers.js b/test/max-headers.js index a08b93154f6..9e7396ae76f 100644 --- a/test/max-headers.js +++ b/test/max-headers.js @@ -2,7 +2,7 @@ const { test } = require('tap') const { Client } = require('..') -const { createServer } = require('http') +const { createServer } = require('node:http') test('handle a lot of headers', (t) => { t.plan(3) diff --git a/test/max-response-size.js b/test/max-response-size.js index 75bfade0351..ca6ad40fa42 100644 --- a/test/max-response-size.js +++ b/test/max-response-size.js @@ -2,7 +2,7 @@ const { test } = require('tap') const { Client, errors } = require('..') -const { createServer } = require('http') +const { createServer } = require('node:http') test('max response size', (t) => { t.plan(4) diff --git a/test/mock-agent.js b/test/mock-agent.js index 66c583da4c5..42dfb9554cc 100644 --- a/test/mock-agent.js +++ b/test/mock-agent.js @@ -1,8 +1,8 @@ 'use strict' const { test } = require('tap') -const { createServer } = require('http') -const { promisify } = require('util') +const { createServer } = require('node:http') +const { promisify } = require('node:util') const { request, setGlobalDispatcher, MockAgent, Agent } = require('..') const { getResponse } = require('../lib/mock/mock-utils') const { kClients, kConnected } = require('../lib/core/symbols') diff --git a/test/mock-client.js b/test/mock-client.js index ef0600e68d2..7845135b139 100644 --- a/test/mock-client.js +++ b/test/mock-client.js @@ -1,8 +1,8 @@ 'use strict' const { test } = require('tap') -const { createServer } = require('http') -const { promisify } = require('util') +const { createServer } = require('node:http') +const { promisify } = require('node:util') const { MockAgent, MockClient, setGlobalDispatcher, request } = require('..') const { kUrl } = require('../lib/core/symbols') const { kDispatches } = require('../lib/mock/mock-symbols') diff --git a/test/mock-pool.js b/test/mock-pool.js index 682d02aab68..fa79796471e 100644 --- a/test/mock-pool.js +++ b/test/mock-pool.js @@ -1,8 +1,8 @@ 'use strict' const { test } = require('tap') -const { createServer } = require('http') -const { promisify } = require('util') +const { createServer } = require('node:http') +const { promisify } = require('node:util') const { MockAgent, MockPool, getGlobalDispatcher, setGlobalDispatcher, request } = require('..') const { kUrl } = require('../lib/core/symbols') const { kDispatches } = require('../lib/mock/mock-symbols') diff --git a/test/no-strict-content-length.js b/test/no-strict-content-length.js index 993b0fdcf7a..b16b82bc38e 100644 --- a/test/no-strict-content-length.js +++ b/test/no-strict-content-length.js @@ -2,8 +2,8 @@ const tap = require('tap') const { Client } = require('..') -const { createServer } = require('http') -const { Readable } = require('stream') +const { createServer } = require('node:http') +const { Readable } = require('node:stream') const sinon = require('sinon') const { wrapWithAsyncIterable } = require('./utils/async-iterators') diff --git a/test/node-fetch/headers.js b/test/node-fetch/headers.js index e509fd8d893..2001e976efa 100644 --- a/test/node-fetch/headers.js +++ b/test/node-fetch/headers.js @@ -1,6 +1,6 @@ /* eslint no-unused-expressions: "off" */ -const { format } = require('util') +const { format } = require('node:util') const chai = require('chai') const chaiIterator = require('chai-iterator') const { Headers } = require('../../lib/fetch/headers.js') diff --git a/test/node-fetch/main.js b/test/node-fetch/main.js index e9f3fe700c8..7e6da3f984f 100644 --- a/test/node-fetch/main.js +++ b/test/node-fetch/main.js @@ -2,15 +2,15 @@ /* globals AbortController */ // Test tools -const zlib = require('zlib') -const stream = require('stream') -const vm = require('vm') +const zlib = require('node:zlib') +const stream = require('node:stream') +const vm = require('node:vm') const chai = require('chai') -const crypto = require('crypto') +const crypto = require('node:crypto') const chaiPromised = require('chai-as-promised') const chaiIterator = require('chai-iterator') const chaiString = require('chai-string') -const { Blob } = require('buffer') +const { Blob } = require('node:buffer') const { setTimeout: delay } = require('timers/promises') const { diff --git a/test/node-fetch/request.js b/test/node-fetch/request.js index 2d29d517f72..405bc2c467e 100644 --- a/test/node-fetch/request.js +++ b/test/node-fetch/request.js @@ -1,8 +1,8 @@ -const stream = require('stream') -const http = require('http') +const stream = require('node:stream') +const http = require('node:http') const chai = require('chai') -const { Blob } = require('buffer') +const { Blob } = require('node:buffer') const Request = require('../../lib/fetch/request.js').Request const TestServer = require('./utils/server.js') diff --git a/test/node-fetch/response.js b/test/node-fetch/response.js index 4bb7c423208..b928651edfa 100644 --- a/test/node-fetch/response.js +++ b/test/node-fetch/response.js @@ -1,10 +1,10 @@ /* eslint no-unused-expressions: "off" */ const chai = require('chai') -const stream = require('stream') +const stream = require('node:stream') const { Response } = require('../../lib/fetch/response.js') const TestServer = require('./utils/server.js') -const { Blob } = require('buffer') +const { Blob } = require('node:buffer') const { kState } = require('../../lib/fetch/symbols.js') const { expect } = chai diff --git a/test/node-fetch/utils/server.js b/test/node-fetch/utils/server.js index 46dc9834fca..548f351a88a 100644 --- a/test/node-fetch/utils/server.js +++ b/test/node-fetch/utils/server.js @@ -1,6 +1,6 @@ -const http = require('http') -const zlib = require('zlib') -const { once } = require('events') +const http = require('node:http') +const zlib = require('node:zlib') +const { once } = require('node:events') const Busboy = require('@fastify/busboy') module.exports = class TestServer { diff --git a/test/node-test/abort-controller.js b/test/node-test/abort-controller.js index 3096e5eba4e..b71ffa7abf7 100644 --- a/test/node-test/abort-controller.js +++ b/test/node-test/abort-controller.js @@ -3,8 +3,8 @@ const { test } = require('node:test') const { AbortController: NPMAbortController } = require('abort-controller') const { Client, errors } = require('../..') -const { createServer } = require('http') -const { createReadStream } = require('fs') +const { createServer } = require('node:http') +const { createReadStream } = require('node:fs') const { wrapWithAsyncIterable } = require('../utils/async-iterators') const { tspl } = require('@matteo.collina/tspl') const { closeServerAsPromise } = require('../utils/node-http') diff --git a/test/node-test/abort-event-emitter.js b/test/node-test/abort-event-emitter.js index 72a009a041e..ad7231331cb 100644 --- a/test/node-test/abort-event-emitter.js +++ b/test/node-test/abort-event-emitter.js @@ -1,11 +1,11 @@ 'use strict' const { test } = require('node:test') -const EventEmitter = require('events') +const EventEmitter = require('node:events') const { Client, errors } = require('../..') -const { createServer } = require('http') -const { createReadStream } = require('fs') -const { Readable } = require('stream') +const { createServer } = require('node:http') +const { createReadStream } = require('node:fs') +const { Readable } = require('node:stream') const { tspl } = require('@matteo.collina/tspl') const { wrapWithAsyncIterable } = require('../utils/async-iterators') const { closeServerAsPromise } = require('../utils/node-http') diff --git a/test/node-test/agent.js b/test/node-test/agent.js index 6ec2156178e..c077fbab4e8 100644 --- a/test/node-test/agent.js +++ b/test/node-test/agent.js @@ -2,8 +2,8 @@ const { describe, test, after } = require('node:test') const assert = require('node:assert/strict') -const http = require('http') -const { PassThrough } = require('stream') +const http = require('node:http') +const { PassThrough } = require('node:stream') const { kRunning } = require('../../lib/core/symbols') const { Agent, diff --git a/test/node-test/async_hooks.js b/test/node-test/async_hooks.js index e670179fec6..4814addde8d 100644 --- a/test/node-test/async_hooks.js +++ b/test/node-test/async_hooks.js @@ -2,10 +2,10 @@ const { test } = require('node:test') const { Client } = require('../..') -const { createServer } = require('http') -const { createHook, executionAsyncId } = require('async_hooks') -const { readFile } = require('fs') -const { PassThrough } = require('stream') +const { createServer } = require('node:http') +const { createHook, executionAsyncId } = require('node:async_hooks') +const { readFile } = require('node:fs') +const { PassThrough } = require('node:stream') const { tspl } = require('@matteo.collina/tspl') const { closeServerAsPromise } = require('../utils/node-http') diff --git a/test/node-test/autoselectfamily.js b/test/node-test/autoselectfamily.js index 67dea1af995..678a8959042 100644 --- a/test/node-test/autoselectfamily.js +++ b/test/node-test/autoselectfamily.js @@ -1,10 +1,10 @@ 'use strict' const { test, skip } = require('node:test') -const dgram = require('dgram') -const { Resolver } = require('dns') +const dgram = require('node:dgram') +const { Resolver } = require('node:dns') const dnsPacket = require('dns-packet') -const { createServer } = require('http') +const { createServer } = require('node:http') const { Client, Agent, request } = require('../..') const { nodeHasAutoSelectFamily } = require('../../lib/core/util') const { tspl } = require('@matteo.collina/tspl') diff --git a/test/node-test/balanced-pool.js b/test/node-test/balanced-pool.js index a47c71c4b6f..564f23979b7 100644 --- a/test/node-test/balanced-pool.js +++ b/test/node-test/balanced-pool.js @@ -4,8 +4,8 @@ const { describe, test } = require('node:test') const assert = require('node:assert/strict') const { BalancedPool, Pool, Client, errors } = require('../..') const { nodeMajor } = require('../../lib/core/util') -const { createServer } = require('http') -const { promisify } = require('util') +const { createServer } = require('node:http') +const { promisify } = require('node:util') const { tspl } = require('@matteo.collina/tspl') test('throws when factory is not a function', (t) => { diff --git a/test/node-test/ca-fingerprint.js b/test/node-test/ca-fingerprint.js index b7fe64eb766..bad8aeff555 100644 --- a/test/node-test/ca-fingerprint.js +++ b/test/node-test/ca-fingerprint.js @@ -1,7 +1,7 @@ 'use strict' -const crypto = require('crypto') -const https = require('https') +const crypto = require('node:crypto') +const https = require('node:https') const { test } = require('node:test') const { Client, buildConnector } = require('../..') const pem = require('https-pem') diff --git a/test/node-test/client-abort.js b/test/node-test/client-abort.js index ebc4fce009b..a5337f16ae2 100644 --- a/test/node-test/client-abort.js +++ b/test/node-test/client-abort.js @@ -2,8 +2,8 @@ const { test } = require('node:test') const { Client, errors } = require('../..') -const { createServer } = require('http') -const { Readable } = require('stream') +const { createServer } = require('node:http') +const { Readable } = require('node:stream') const { tspl } = require('@matteo.collina/tspl') class OnAbortError extends Error {} diff --git a/test/node-test/client-connect.js b/test/node-test/client-connect.js index 7de9d2e39e3..0bf65488d81 100644 --- a/test/node-test/client-connect.js +++ b/test/node-test/client-connect.js @@ -2,8 +2,8 @@ const { test } = require('node:test') const { Client, errors } = require('../..') -const http = require('http') -const EE = require('events') +const http = require('node:http') +const EE = require('node:events') const { kBusy } = require('../../lib/core/symbols') const { tspl } = require('@matteo.collina/tspl') const { closeServerAsPromise } = require('../utils/node-http') diff --git a/test/node-test/client-dispatch.js b/test/node-test/client-dispatch.js index 42fbf91b412..b89bad7278b 100644 --- a/test/node-test/client-dispatch.js +++ b/test/node-test/client-dispatch.js @@ -2,9 +2,9 @@ const { test } = require('node:test') const assert = require('node:assert/strict') -const http = require('http') +const http = require('node:http') const { Client, Pool, errors } = require('../..') -const stream = require('stream') +const stream = require('node:stream') const { createSecureServer } = require('node:http2') const pem = require('https-pem') const { tspl } = require('@matteo.collina/tspl') diff --git a/test/node-test/client-errors.js b/test/node-test/client-errors.js index 72ae7c7a0fd..41389088425 100644 --- a/test/node-test/client-errors.js +++ b/test/node-test/client-errors.js @@ -3,10 +3,10 @@ const { test } = require('node:test') const assert = require('node:assert') const { Client, Pool, errors } = require('../..') -const { createServer } = require('http') -const https = require('https') +const { createServer } = require('node:http') +const https = require('node:https') const pem = require('https-pem') -const { Readable } = require('stream') +const { Readable } = require('node:stream') const { tspl } = require('@matteo.collina/tspl') const { kSocket } = require('../../lib/core/symbols') diff --git a/test/node-test/diagnostics-channel/connect-error.js b/test/node-test/diagnostics-channel/connect-error.js index 1cc255c8d46..ecab3856b89 100644 --- a/test/node-test/diagnostics-channel/connect-error.js +++ b/test/node-test/diagnostics-channel/connect-error.js @@ -6,7 +6,7 @@ const { tspl } = require('@matteo.collina/tspl') let diagnosticsChannel try { - diagnosticsChannel = require('diagnostics_channel') + diagnosticsChannel = require('node:diagnostics_channel') } catch { skip('missing diagnostics_channel') process.exit(0) diff --git a/test/node-test/diagnostics-channel/error.js b/test/node-test/diagnostics-channel/error.js index 9b320b59824..b4861b8f71c 100644 --- a/test/node-test/diagnostics-channel/error.js +++ b/test/node-test/diagnostics-channel/error.js @@ -6,14 +6,14 @@ const { tspl } = require('@matteo.collina/tspl') let diagnosticsChannel try { - diagnosticsChannel = require('diagnostics_channel') + diagnosticsChannel = require('node:diagnostics_channel') } catch { skip('missing diagnostics_channel') process.exit(0) } const { Client } = require('../../..') -const { createServer } = require('http') +const { createServer } = require('node:http') test('Diagnostics channel - error', (t) => { const assert = tspl(t, { plan: 3 }) diff --git a/test/node-test/diagnostics-channel/get.js b/test/node-test/diagnostics-channel/get.js index a41df9d2563..cde68a46f2c 100644 --- a/test/node-test/diagnostics-channel/get.js +++ b/test/node-test/diagnostics-channel/get.js @@ -6,14 +6,14 @@ const { tspl } = require('@matteo.collina/tspl') let diagnosticsChannel try { - diagnosticsChannel = require('diagnostics_channel') + diagnosticsChannel = require('node:diagnostics_channel') } catch { skip('missing diagnostics_channel') process.exit(0) } const { Client } = require('../../..') -const { createServer } = require('http') +const { createServer } = require('node:http') test('Diagnostics channel - get', (t) => { const assert = tspl(t, { plan: 32 }) diff --git a/test/node-test/diagnostics-channel/post-stream.js b/test/node-test/diagnostics-channel/post-stream.js index aa2792a2732..a50d5ea02c0 100644 --- a/test/node-test/diagnostics-channel/post-stream.js +++ b/test/node-test/diagnostics-channel/post-stream.js @@ -2,19 +2,19 @@ const { test, skip, after } = require('node:test') const { tspl } = require('@matteo.collina/tspl') -const { Readable } = require('stream') +const { Readable } = require('node:stream') let diagnosticsChannel try { - diagnosticsChannel = require('diagnostics_channel') + diagnosticsChannel = require('node:diagnostics_channel') } catch { skip('missing diagnostics_channel') process.exit(0) } const { Client } = require('../../..') -const { createServer } = require('http') +const { createServer } = require('node:http') test('Diagnostics channel - post stream', (t) => { const assert = tspl(t, { plan: 33 }) diff --git a/test/node-test/diagnostics-channel/post.js b/test/node-test/diagnostics-channel/post.js index 427853b66ea..45368e3fdab 100644 --- a/test/node-test/diagnostics-channel/post.js +++ b/test/node-test/diagnostics-channel/post.js @@ -6,14 +6,14 @@ const { tspl } = require('@matteo.collina/tspl') let diagnosticsChannel try { - diagnosticsChannel = require('diagnostics_channel') + diagnosticsChannel = require('node:diagnostics_channel') } catch { skip('missing diagnostics_channel') process.exit(0) } const { Client } = require('../../../') -const { createServer } = require('http') +const { createServer } = require('node:http') test('Diagnostics channel - post', (t) => { const assert = tspl(t, { plan: 33 }) diff --git a/test/node-test/large-body.js b/test/node-test/large-body.js index 4fbe5b7a9b7..8707fe04d03 100644 --- a/test/node-test/large-body.js +++ b/test/node-test/large-body.js @@ -1,7 +1,7 @@ 'use strict' const { test } = require('node:test') -const { createServer } = require('http') +const { createServer } = require('node:http') const { request } = require('../../') const { strictEqual } = require('node:assert') diff --git a/test/node-test/unix.js b/test/node-test/unix.js index 3e2032e500b..629ea883115 100644 --- a/test/node-test/unix.js +++ b/test/node-test/unix.js @@ -2,10 +2,10 @@ const { test } = require('node:test') const { Client, Pool } = require('../../') -const http = require('http') -const https = require('https') +const http = require('node:http') +const https = require('node:https') const pem = require('https-pem') -const fs = require('fs') +const fs = require('node:fs') const { tspl } = require('@matteo.collina/tspl') if (process.platform !== 'win32') { diff --git a/test/node-test/util.js b/test/node-test/util.js index d3305126cec..9d18f98d596 100644 --- a/test/node-test/util.js +++ b/test/node-test/util.js @@ -2,8 +2,8 @@ const { test } = require('node:test') const assert = require('node:assert') -const { Stream } = require('stream') -const { EventEmitter } = require('events') +const { Stream } = require('node:stream') +const { EventEmitter } = require('node:events') const util = require('../../lib/core/util') const { headerNameLowerCasedRecord } = require('../../lib/core/constants') diff --git a/test/node-test/validations.js b/test/node-test/validations.js index 99e3f505bde..f23f910ed21 100644 --- a/test/node-test/validations.js +++ b/test/node-test/validations.js @@ -1,7 +1,7 @@ 'use strict' const { test } = require('node:test') -const { createServer } = require('http') +const { createServer } = require('node:http') const { Client } = require('../../') const { tspl } = require('@matteo.collina/tspl') diff --git a/test/parser-issues.js b/test/parser-issues.js index b98edf159ef..c94e8cf04bc 100644 --- a/test/parser-issues.js +++ b/test/parser-issues.js @@ -1,4 +1,4 @@ -const net = require('net') +const net = require('node:net') const { test } = require('tap') const { Client, errors } = require('..') diff --git a/test/pipeline-pipelining.js b/test/pipeline-pipelining.js index 52a29d799b2..4a94e38375f 100644 --- a/test/pipeline-pipelining.js +++ b/test/pipeline-pipelining.js @@ -2,7 +2,7 @@ const { test } = require('tap') const { Client } = require('..') -const { createServer } = require('http') +const { createServer } = require('node:http') const { kConnect } = require('../lib/core/symbols') const { kBusy, kPending, kRunning } = require('../lib/core/symbols') diff --git a/test/pool.js b/test/pool.js index 816bc5e2d31..0d586655b9f 100644 --- a/test/pool.js +++ b/test/pool.js @@ -1,14 +1,14 @@ 'use strict' -const { EventEmitter } = require('events') -const { createServer } = require('http') -const net = require('net') +const { EventEmitter } = require('node:events') +const { createServer } = require('node:http') +const net = require('node:net') const { finished, PassThrough, Readable -} = require('stream') -const { promisify } = require('util') +} = require('node:stream') +const { promisify } = require('node:util') const proxyquire = require('proxyquire') const { test } = require('tap') const { diff --git a/test/promises.js b/test/promises.js index 524fdfc8178..4188a125bd9 100644 --- a/test/promises.js +++ b/test/promises.js @@ -2,8 +2,8 @@ const { test } = require('tap') const { Client, Pool } = require('..') -const { createServer } = require('http') -const { readFileSync, createReadStream } = require('fs') +const { createServer } = require('node:http') +const { readFileSync, createReadStream } = require('node:fs') const { wrapWithAsyncIterable } = require('./utils/async-iterators') test('basic get, async await support', (t) => { diff --git a/test/proxy-agent.js b/test/proxy-agent.js index 42332389793..806f02a2d55 100644 --- a/test/proxy-agent.js +++ b/test/proxy-agent.js @@ -3,12 +3,12 @@ const { test, teardown } = require('tap') const { request, fetch, setGlobalDispatcher, getGlobalDispatcher } = require('..') const { InvalidArgumentError } = require('../lib/core/errors') -const { readFileSync } = require('fs') -const { join } = require('path') +const { readFileSync } = require('node:fs') +const { join } = require('node:path') const ProxyAgent = require('../lib/proxy-agent') const Pool = require('../lib/pool') -const { createServer } = require('http') -const https = require('https') +const { createServer } = require('node:http') +const https = require('node:https') const proxy = require('proxy') test('should throw error when no uri is provided', (t) => { diff --git a/test/proxy.js b/test/proxy.js index d6d8d42f17d..c910d7224d1 100644 --- a/test/proxy.js +++ b/test/proxy.js @@ -2,7 +2,7 @@ const { test } = require('tap') const { Client, Pool } = require('..') -const { createServer } = require('http') +const { createServer } = require('node:http') const proxy = require('proxy') test('connect through proxy', async (t) => { diff --git a/test/redirect-pipeline.js b/test/redirect-pipeline.js index e4be837c6e9..d958ee513f1 100644 --- a/test/redirect-pipeline.js +++ b/test/redirect-pipeline.js @@ -2,8 +2,8 @@ const t = require('tap') const { pipeline: undiciPipeline } = require('..') -const { pipeline: streamPipelineCb } = require('stream') -const { promisify } = require('util') +const { pipeline: streamPipelineCb } = require('node:stream') +const { promisify } = require('node:util') const { createReadable, createWritable } = require('./utils/stream') const { startRedirectingServer } = require('./utils/redirecting-servers') diff --git a/test/request-crlf.js b/test/request-crlf.js index abcecf091f5..f3572062491 100644 --- a/test/request-crlf.js +++ b/test/request-crlf.js @@ -1,6 +1,6 @@ 'use strict' -const { createServer } = require('http') +const { createServer } = require('node:http') const { test } = require('tap') const { request, errors } = require('..') diff --git a/test/request-timeout.js b/test/request-timeout.js index 6ac19735394..49d29a6223c 100644 --- a/test/request-timeout.js +++ b/test/request-timeout.js @@ -1,12 +1,12 @@ 'use strict' const { test } = require('tap') -const { createReadStream, writeFileSync, unlinkSync } = require('fs') +const { createReadStream, writeFileSync, unlinkSync } = require('node:fs') const { Client, errors } = require('..') const { kConnect } = require('../lib/core/symbols') const timers = require('../lib/timers') -const { createServer } = require('http') -const EventEmitter = require('events') +const { createServer } = require('node:http') +const EventEmitter = require('node:events') const FakeTimers = require('@sinonjs/fake-timers') const { AbortController } = require('abort-controller') const { @@ -14,7 +14,7 @@ const { Readable, Writable, PassThrough -} = require('stream') +} = require('node:stream') test('request timeout', (t) => { t.plan(1) diff --git a/test/request-timeout2.js b/test/request-timeout2.js index 53943fbf5d3..ff4f1ddfebc 100644 --- a/test/request-timeout2.js +++ b/test/request-timeout2.js @@ -2,8 +2,8 @@ const { test } = require('tap') const { Client } = require('..') -const { createServer } = require('http') -const { Readable } = require('stream') +const { createServer } = require('node:http') +const { Readable } = require('node:stream') test('request timeout with slow readable body', (t) => { t.plan(1) diff --git a/test/request.js b/test/request.js index d3a2f7484b1..30bf745c3f1 100644 --- a/test/request.js +++ b/test/request.js @@ -1,6 +1,6 @@ 'use strict' -const { createServer } = require('http') +const { createServer } = require('node:http') const { test } = require('tap') const { request } = require('..') diff --git a/test/socket-back-pressure.js b/test/socket-back-pressure.js index 9e774b3de6a..325ac993933 100644 --- a/test/socket-back-pressure.js +++ b/test/socket-back-pressure.js @@ -1,8 +1,8 @@ 'use strict' const { Client } = require('..') -const { createServer } = require('http') -const { Readable } = require('stream') +const { createServer } = require('node:http') +const { Readable } = require('node:stream') const { test } = require('tap') test('socket back-pressure', (t) => { diff --git a/test/socket-timeout.js b/test/socket-timeout.js index 8019c74198a..eb9670c6020 100644 --- a/test/socket-timeout.js +++ b/test/socket-timeout.js @@ -3,7 +3,7 @@ const { test } = require('tap') const { Client, errors } = require('..') const timers = require('../lib/timers') -const { createServer } = require('http') +const { createServer } = require('node:http') const FakeTimers = require('@sinonjs/fake-timers') test('timeout with pipelining 1', (t) => { diff --git a/test/stream-compat.js b/test/stream-compat.js index 71d2410ee36..02d521a9d65 100644 --- a/test/stream-compat.js +++ b/test/stream-compat.js @@ -2,9 +2,9 @@ const { test } = require('tap') const { Client } = require('..') -const { createServer } = require('http') -const { Readable } = require('stream') -const EE = require('events') +const { createServer } = require('node:http') +const { Readable } = require('node:stream') +const EE = require('node:events') test('stream body without destroy', (t) => { t.plan(2) diff --git a/test/tls-session-reuse.js b/test/tls-session-reuse.js index 7a7657b4e4c..ae65571bfa2 100644 --- a/test/tls-session-reuse.js +++ b/test/tls-session-reuse.js @@ -1,9 +1,9 @@ 'use strict' -const { readFileSync } = require('fs') -const { join } = require('path') -const https = require('https') -const crypto = require('crypto') +const { readFileSync } = require('node:fs') +const { join } = require('node:path') +const https = require('node:https') +const crypto = require('node:crypto') const { test, teardown } = require('tap') const { Client, Pool } = require('..') const { kSocket } = require('../lib/core/symbols') diff --git a/test/tls.js b/test/tls.js index fbe07b09beb..cd4660fa319 100644 --- a/test/tls.js +++ b/test/tls.js @@ -5,7 +5,7 @@ // const { test } = require('tap') // const { Client } = require('..') // const { kSocket } = require('../lib/core/symbols') -// const { Readable } = require('stream') +// const { Readable } = require('node:stream') // const { kRunning } = require('../lib/core/symbols') // test('tls get 1', (t) => { diff --git a/test/trailers.js b/test/trailers.js index ca56de23cc5..e56542568ab 100644 --- a/test/trailers.js +++ b/test/trailers.js @@ -2,7 +2,7 @@ const { test } = require('tap') const { Client } = require('..') -const { createServer } = require('http') +const { createServer } = require('node:http') test('response trailers missing is OK', (t) => { t.plan(1) diff --git a/test/utils/redirecting-servers.js b/test/utils/redirecting-servers.js index ad8aa583fdb..0125fc55748 100644 --- a/test/utils/redirecting-servers.js +++ b/test/utils/redirecting-servers.js @@ -1,6 +1,6 @@ 'use strict' -const { createServer } = require('http') +const { createServer } = require('node:http') const isNode20 = process.version.startsWith('v20.') diff --git a/test/utils/stream.js b/test/utils/stream.js index e35ca29fe44..9c35d9fa9d4 100644 --- a/test/utils/stream.js +++ b/test/utils/stream.js @@ -1,6 +1,6 @@ 'use strict' -const { Readable, Writable } = require('stream') +const { Readable, Writable } = require('node:stream') function createReadable (data) { return new Readable({ diff --git a/test/websocket/custom-headers.js b/test/websocket/custom-headers.js index 11611a84c0a..ebe3ae541ab 100644 --- a/test/websocket/custom-headers.js +++ b/test/websocket/custom-headers.js @@ -1,7 +1,7 @@ 'use strict' const { test } = require('node:test') -const assert = require('assert') +const assert = require('node:assert') const { Agent, WebSocket } = require('../..') test('Setting custom headers', (t) => { diff --git a/test/websocket/diagnostics-channel.js b/test/websocket/diagnostics-channel.js index fbd75ceca8c..b11a06e6ea9 100644 --- a/test/websocket/diagnostics-channel.js +++ b/test/websocket/diagnostics-channel.js @@ -2,7 +2,7 @@ const { describe, test } = require('node:test') const assert = require('node:assert') -const dc = require('diagnostics_channel') +const dc = require('node:diagnostics_channel') const { WebSocketServer } = require('ws') const { WebSocket } = require('../..') diff --git a/test/websocket/fragments.js b/test/websocket/fragments.js index 3c798302f80..a4a168fe7cb 100644 --- a/test/websocket/fragments.js +++ b/test/websocket/fragments.js @@ -4,7 +4,7 @@ const assert = require('node:assert') const { test, after } = require('node:test') const { WebSocketServer } = require('ws') const { WebSocket } = require('../..') -const diagnosticsChannel = require('diagnostics_channel') +const diagnosticsChannel = require('node:diagnostics_channel') test('Fragmented frame with a ping frame in the middle of it', () => { const server = new WebSocketServer({ port: 0 }) diff --git a/test/websocket/opening-handshake.js b/test/websocket/opening-handshake.js index 4dce496e829..110a827edc9 100644 --- a/test/websocket/opening-handshake.js +++ b/test/websocket/opening-handshake.js @@ -2,7 +2,7 @@ const { test } = require('node:test') const assert = require('node:assert') -const { createServer } = require('http') +const { createServer } = require('node:http') const { WebSocketServer } = require('ws') const { WebSocket } = require('../..') @@ -155,7 +155,7 @@ test('Server sends invalid Sec-WebSocket-Accept header', () => { test('Server sends invalid Sec-WebSocket-Extensions header', () => { return new Promise((resolve, reject) => { const uid = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11' - const { createHash } = require('crypto') + const { createHash } = require('node:crypto') const server = createServer((req, res) => { const key = req.headers['sec-websocket-key'] @@ -186,7 +186,7 @@ test('Server sends invalid Sec-WebSocket-Extensions header', () => { test('Server sends invalid Sec-WebSocket-Extensions header', () => { const uid = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11' - const { createHash } = require('crypto') + const { createHash } = require('node:crypto') return new Promise((resolve, reject) => { const server = createServer((req, res) => { diff --git a/test/websocket/ping-pong.js b/test/websocket/ping-pong.js index 81ae3a478ec..0a30f239a6d 100644 --- a/test/websocket/ping-pong.js +++ b/test/websocket/ping-pong.js @@ -3,7 +3,7 @@ const { test } = require('node:test') const assert = require('node:assert') const { WebSocketServer } = require('ws') -const diagnosticsChannel = require('diagnostics_channel') +const diagnosticsChannel = require('node:diagnostics_channel') const { WebSocket } = require('../..') test('Receives ping and parses body', () => { diff --git a/test/websocket/send.js b/test/websocket/send.js index bd49ce95766..b2b153829da 100644 --- a/test/websocket/send.js +++ b/test/websocket/send.js @@ -3,7 +3,7 @@ const { test, describe } = require('node:test') const assert = require('node:assert') const { WebSocketServer } = require('ws') -const { Blob } = require('buffer') +const { Blob } = require('node:buffer') const { WebSocket } = require('../..') // the following three tests exercise different code paths because of the three