Skip to content

Commit

Permalink
deps: update undici to 6.19.2
Browse files Browse the repository at this point in the history
PR-URL: #53468
Reviewed-By: Marco Ippolito <[email protected]>
Reviewed-By: Chemi Atlow <[email protected]>
Reviewed-By: Matthew Aitken <[email protected]>
Reviewed-By: Rafael Gonzaga <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
  • Loading branch information
nodejs-github-bot authored and targos committed Jun 20, 2024
1 parent c4a7e05 commit e69b8d2
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 69 deletions.
22 changes: 10 additions & 12 deletions deps/undici/src/lib/web/fetch/body.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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 () {
Expand Down Expand Up @@ -384,16 +383,16 @@ 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 () {
// The bytes() method steps are to return the result of running consume body
// 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)
}
}

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 3 additions & 11 deletions deps/undici/src/lib/web/fetch/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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)
}
Expand Down Expand Up @@ -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

Expand All @@ -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)
}

Expand Down
4 changes: 2 additions & 2 deletions deps/undici/src/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions deps/undici/src/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion deps/undici/src/types/formdata.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/// <reference types="node" />

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.
Expand Down
8 changes: 2 additions & 6 deletions deps/undici/src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
18 changes: 11 additions & 7 deletions deps/undici/src/types/interceptors.d.ts
Original file line number Diff line number Diff line change
@@ -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
}
3 changes: 0 additions & 3 deletions deps/undici/src/types/retry-agent.d.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions deps/undici/src/types/webidl.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ interface WebidlUtil {
V: unknown,
bitLength: number,
signedness: 'signed' | 'unsigned',
opts?: ConvertToIntOpts,
prefix: string,
argument: string
opts?: ConvertToIntOpts
): number

/**
Expand Down
33 changes: 13 additions & 20 deletions deps/undici/undici.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -4378,7 +4378,7 @@ var require_util2 = __commonJS({
return;
}
try {
successSteps(await readAllBytes(reader, shouldClone));
successSteps(await readAllBytes(reader));
} catch (e) {
errorSteps(e);
}
Expand All @@ -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)) {
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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;
Expand All @@ -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");
Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/undici_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_

0 comments on commit e69b8d2

Please sign in to comment.