diff --git a/deps/undici/src/lib/web/fetch/body.js b/deps/undici/src/lib/web/fetch/body.js index 5b14d22d27a854..55718ac7c8165d 100644 --- a/deps/undici/src/lib/web/fetch/body.js +++ b/deps/undici/src/lib/web/fetch/body.js @@ -309,7 +309,7 @@ function bodyMixinMethods (instance) { // Return a Blob whose contents are bytes and type attribute // is mimeType. return new Blob([bytes], { type: mimeType }) - }, instance, false) + }, instance) }, arrayBuffer () { @@ -318,21 +318,20 @@ function bodyMixinMethods (instance) { // given a byte sequence bytes: return a new ArrayBuffer // whose contents are bytes. return consumeBody(this, (bytes) => { - // Note: arrayBuffer already cloned. - return bytes.buffer - }, instance, true) + return new Uint8Array(bytes).buffer + }, instance) }, text () { // The text() method steps are to return the result of running // consume body with this and UTF-8 decode. - return consumeBody(this, utf8DecodeBytes, instance, false) + return consumeBody(this, utf8DecodeBytes, instance) }, json () { // The json() method steps are to return the result of running // consume body with this and parse JSON from bytes. - return consumeBody(this, parseJSONFromBytes, instance, false) + return consumeBody(this, parseJSONFromBytes, instance) }, formData () { @@ -384,7 +383,7 @@ function bodyMixinMethods (instance) { throw new TypeError( 'Content-Type was not one of "multipart/form-data" or "application/x-www-form-urlencoded".' ) - }, instance, false) + }, instance) }, bytes () { @@ -392,8 +391,8 @@ function bodyMixinMethods (instance) { // with this and the following step given a byte sequence bytes: return the // result of creating a Uint8Array from bytes in this’s relevant realm. return consumeBody(this, (bytes) => { - return new Uint8Array(bytes.buffer, 0, bytes.byteLength) - }, instance, true) + return new Uint8Array(bytes) + }, instance) } } @@ -409,9 +408,8 @@ function mixinBody (prototype) { * @param {Response|Request} object * @param {(value: unknown) => unknown} convertBytesToJSValue * @param {Response|Request} instance - * @param {boolean} [shouldClone] */ -async function consumeBody (object, convertBytesToJSValue, instance, shouldClone) { +async function consumeBody (object, convertBytesToJSValue, instance) { webidl.brandCheck(object, instance) // 1. If object is unusable, then return a promise rejected @@ -449,7 +447,7 @@ async function consumeBody (object, convertBytesToJSValue, instance, shouldClone // 6. Otherwise, fully read object’s body given successSteps, // errorSteps, and object’s relevant global object. - await fullyReadBody(object[kState].body, successSteps, errorSteps, shouldClone) + await fullyReadBody(object[kState].body, successSteps, errorSteps) // 7. Return promise. return promise.promise diff --git a/deps/undici/src/lib/web/fetch/util.js b/deps/undici/src/lib/web/fetch/util.js index b7e42870f3e485..dc5ce9b392a68b 100644 --- a/deps/undici/src/lib/web/fetch/util.js +++ b/deps/undici/src/lib/web/fetch/util.js @@ -1029,7 +1029,7 @@ function iteratorMixin (name, object, kInternalIterator, keyIndex = 0, valueInde /** * @see https://fetch.spec.whatwg.org/#body-fully-read */ -async function fullyReadBody (body, processBody, processBodyError, shouldClone) { +async function fullyReadBody (body, processBody, processBodyError) { // 1. If taskDestination is null, then set taskDestination to // the result of starting a new parallel queue. @@ -1055,7 +1055,7 @@ async function fullyReadBody (body, processBody, processBodyError, shouldClone) // 5. Read all bytes from reader, given successSteps and errorSteps. try { - successSteps(await readAllBytes(reader, shouldClone)) + successSteps(await readAllBytes(reader)) } catch (e) { errorSteps(e) } @@ -1103,9 +1103,8 @@ function isomorphicEncode (input) { * @see https://streams.spec.whatwg.org/#readablestreamdefaultreader-read-all-bytes * @see https://streams.spec.whatwg.org/#read-loop * @param {ReadableStreamDefaultReader} reader - * @param {boolean} [shouldClone] */ -async function readAllBytes (reader, shouldClone) { +async function readAllBytes (reader) { const bytes = [] let byteLength = 0 @@ -1114,13 +1113,6 @@ async function readAllBytes (reader, shouldClone) { if (done) { // 1. Call successSteps with bytes. - if (bytes.length === 1) { - const { buffer, byteOffset, byteLength } = bytes[0] - if (shouldClone === false) { - return Buffer.from(buffer, byteOffset, byteLength) - } - return Buffer.from(buffer.slice(byteOffset, byteOffset + byteLength), 0, byteLength) - } return Buffer.concat(bytes, byteLength) } diff --git a/deps/undici/src/package-lock.json b/deps/undici/src/package-lock.json index 926db8a57da54f..91ada55a0d9cbb 100644 --- a/deps/undici/src/package-lock.json +++ b/deps/undici/src/package-lock.json @@ -1,12 +1,12 @@ { "name": "undici", - "version": "6.19.1", + "version": "6.19.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "undici", - "version": "6.19.1", + "version": "6.19.2", "license": "MIT", "devDependencies": { "@fastify/busboy": "2.1.1", diff --git a/deps/undici/src/package.json b/deps/undici/src/package.json index 8bf2adab7008a3..8187dad6884de6 100644 --- a/deps/undici/src/package.json +++ b/deps/undici/src/package.json @@ -1,6 +1,6 @@ { "name": "undici", - "version": "6.19.1", + "version": "6.19.2", "description": "An HTTP/1.1 client, written from scratch for Node.js", "homepage": "https://undici.nodejs.org", "bugs": { @@ -85,7 +85,7 @@ "test:node-test": "borp -p \"test/node-test/**/*.js\"", "test:tdd": "borp --expose-gc -p \"test/*.js\"", "test:tdd:node-test": "borp -p \"test/node-test/**/*.js\" -w", - "test:typescript": "tsd && tsc --skipLibCheck test/imports/undici-import.ts", + "test:typescript": "tsd && tsc test/imports/undici-import.ts --typeRoots ./types && tsc ./types/*.d.ts --noEmit --typeRoots ./types", "test:webidl": "borp -p \"test/webidl/*.js\"", "test:websocket": "borp -p \"test/websocket/*.js\"", "test:websocket:autobahn": "node test/autobahn/client.js", @@ -99,7 +99,7 @@ "coverage:report:ci": "c8 report", "bench": "echo \"Error: Benchmarks have been moved to '/benchmarks'\" && exit 1", "serve:website": "echo \"Error: Documentation has been moved to '/docs'\" && exit 1", - "prepare": "husky install && node ./scripts/platform-shell.js" + "prepare": "husky && node ./scripts/platform-shell.js" }, "devDependencies": { "@fastify/busboy": "2.1.1", diff --git a/deps/undici/src/types/formdata.d.ts b/deps/undici/src/types/formdata.d.ts index df29a572d6bd4f..e676b11ec342a3 100644 --- a/deps/undici/src/types/formdata.d.ts +++ b/deps/undici/src/types/formdata.d.ts @@ -2,7 +2,7 @@ /// import { File } from './file' -import { SpecIterator, SpecIterableIterator } from './fetch' +import { SpecIterableIterator } from './fetch' /** * A `string` or `File` that represents a single value from a set of `FormData` key-value pairs. diff --git a/deps/undici/src/types/index.d.ts b/deps/undici/src/types/index.d.ts index 18657b6aeb7b6c..f6be35cd9bf40d 100644 --- a/deps/undici/src/types/index.d.ts +++ b/deps/undici/src/types/index.d.ts @@ -42,7 +42,7 @@ declare namespace Undici { var RedirectHandler: typeof import ('./handlers').RedirectHandler var DecoratorHandler: typeof import ('./handlers').DecoratorHandler var RetryHandler: typeof import ('./retry-handler').default - var createRedirectInterceptor: typeof import ('./interceptors').createRedirectInterceptor + var createRedirectInterceptor: typeof import ('./interceptors').default.createRedirectInterceptor var BalancedPool: typeof import('./balanced-pool').default; var Client: typeof import('./client').default; var buildConnector: typeof import('./connector').default; @@ -67,9 +67,5 @@ declare namespace Undici { var File: typeof import('./file').File; var FileReader: typeof import('./filereader').FileReader; var caches: typeof import('./cache').caches; - var interceptors: { - dump: typeof import('./interceptors').dump; - retry: typeof import('./interceptors').retry; - redirect: typeof import('./interceptors').redirect; - } + var interceptors: typeof import('./interceptors').default; } diff --git a/deps/undici/src/types/interceptors.d.ts b/deps/undici/src/types/interceptors.d.ts index d546ac344e3689..fab6da08c0d9b5 100644 --- a/deps/undici/src/types/interceptors.d.ts +++ b/deps/undici/src/types/interceptors.d.ts @@ -1,11 +1,15 @@ import Dispatcher from "./dispatcher"; import RetryHandler from "./retry-handler"; -export type DumpInterceptorOpts = { maxSize?: number } -export type RetryInterceptorOpts = RetryHandler.RetryOptions -export type RedirectInterceptorOpts = { maxRedirections?: number } +export default Interceptors; -export declare function createRedirectInterceptor (opts: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor -export declare function dump(opts?: DumpInterceptorOpts): Dispatcher.DispatcherComposeInterceptor -export declare function retry(opts?: RetryInterceptorOpts): Dispatcher.DispatcherComposeInterceptor -export declare function redirect(opts?: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor +declare namespace Interceptors { + export type DumpInterceptorOpts = { maxSize?: number } + export type RetryInterceptorOpts = RetryHandler.RetryOptions + export type RedirectInterceptorOpts = { maxRedirections?: number } + + export function createRedirectInterceptor(opts: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor + export function dump(opts?: DumpInterceptorOpts): Dispatcher.DispatcherComposeInterceptor + export function retry(opts?: RetryInterceptorOpts): Dispatcher.DispatcherComposeInterceptor + export function redirect(opts?: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor +} diff --git a/deps/undici/src/types/retry-agent.d.ts b/deps/undici/src/types/retry-agent.d.ts index cf559d956e504f..963cea99e42c84 100644 --- a/deps/undici/src/types/retry-agent.d.ts +++ b/deps/undici/src/types/retry-agent.d.ts @@ -1,7 +1,4 @@ -import Agent from './agent' -import buildConnector from './connector'; import Dispatcher from './dispatcher' -import { IncomingHttpHeaders } from './header' import RetryHandler from './retry-handler' export default RetryAgent diff --git a/deps/undici/src/types/webidl.d.ts b/deps/undici/src/types/webidl.d.ts index fe802a201245fb..8a23a85bf0100a 100644 --- a/deps/undici/src/types/webidl.d.ts +++ b/deps/undici/src/types/webidl.d.ts @@ -55,9 +55,7 @@ interface WebidlUtil { V: unknown, bitLength: number, signedness: 'signed' | 'unsigned', - opts?: ConvertToIntOpts, - prefix: string, - argument: string + opts?: ConvertToIntOpts ): number /** diff --git a/deps/undici/undici.js b/deps/undici/undici.js index 0bcbe10d575c8d..6db2e4ce249f34 100644 --- a/deps/undici/undici.js +++ b/deps/undici/undici.js @@ -4367,7 +4367,7 @@ var require_util2 = __commonJS({ }); } __name(iteratorMixin, "iteratorMixin"); - async function fullyReadBody(body, processBody, processBodyError, shouldClone) { + async function fullyReadBody(body, processBody, processBodyError) { const successSteps = processBody; const errorSteps = processBodyError; let reader; @@ -4378,7 +4378,7 @@ var require_util2 = __commonJS({ return; } try { - successSteps(await readAllBytes(reader, shouldClone)); + successSteps(await readAllBytes(reader)); } catch (e) { errorSteps(e); } @@ -4405,19 +4405,12 @@ var require_util2 = __commonJS({ return input; } __name(isomorphicEncode, "isomorphicEncode"); - async function readAllBytes(reader, shouldClone) { + async function readAllBytes(reader) { const bytes = []; let byteLength = 0; while (true) { const { done, value: chunk } = await reader.read(); if (done) { - if (bytes.length === 1) { - const { buffer, byteOffset, byteLength: byteLength2 } = bytes[0]; - if (shouldClone === false) { - return Buffer.from(buffer, byteOffset, byteLength2); - } - return Buffer.from(buffer.slice(byteOffset, byteOffset + byteLength2), 0, byteLength2); - } return Buffer.concat(bytes, byteLength); } if (!isUint8Array(chunk)) { @@ -5393,18 +5386,18 @@ Content-Type: ${value.type || "application/octet-stream"}\r mimeType = serializeAMimeType(mimeType); } return new Blob2([bytes], { type: mimeType }); - }, instance, false); + }, instance); }, arrayBuffer() { return consumeBody(this, (bytes) => { - return bytes.buffer; - }, instance, true); + return new Uint8Array(bytes).buffer; + }, instance); }, text() { - return consumeBody(this, utf8DecodeBytes, instance, false); + return consumeBody(this, utf8DecodeBytes, instance); }, json() { - return consumeBody(this, parseJSONFromBytes, instance, false); + return consumeBody(this, parseJSONFromBytes, instance); }, formData() { return consumeBody(this, (value) => { @@ -5433,12 +5426,12 @@ Content-Type: ${value.type || "application/octet-stream"}\r throw new TypeError( 'Content-Type was not one of "multipart/form-data" or "application/x-www-form-urlencoded".' ); - }, instance, false); + }, instance); }, bytes() { return consumeBody(this, (bytes) => { - return new Uint8Array(bytes.buffer, 0, bytes.byteLength); - }, instance, true); + return new Uint8Array(bytes); + }, instance); } }; return methods; @@ -5448,7 +5441,7 @@ Content-Type: ${value.type || "application/octet-stream"}\r Object.assign(prototype.prototype, bodyMixinMethods(prototype)); } __name(mixinBody, "mixinBody"); - async function consumeBody(object, convertBytesToJSValue, instance, shouldClone) { + async function consumeBody(object, convertBytesToJSValue, instance) { webidl.brandCheck(object, instance); if (bodyUnusable(object[kState].body)) { throw new TypeError("Body is unusable: Body has already been read"); @@ -5467,7 +5460,7 @@ Content-Type: ${value.type || "application/octet-stream"}\r successSteps(Buffer.allocUnsafe(0)); return promise.promise; } - await fullyReadBody(object[kState].body, successSteps, errorSteps, shouldClone); + await fullyReadBody(object[kState].body, successSteps, errorSteps); return promise.promise; } __name(consumeBody, "consumeBody"); diff --git a/src/undici_version.h b/src/undici_version.h index ec1879873efb49..8fd646706ca701 100644 --- a/src/undici_version.h +++ b/src/undici_version.h @@ -2,5 +2,5 @@ // Refer to tools/dep_updaters/update-undici.sh #ifndef SRC_UNDICI_VERSION_H_ #define SRC_UNDICI_VERSION_H_ -#define UNDICI_VERSION "6.19.1" +#define UNDICI_VERSION "6.19.2" #endif // SRC_UNDICI_VERSION_H_