Skip to content

Commit e69b8d2

Browse files
nodejs-github-bottargos
authored andcommittedJun 20, 2024
deps: update undici to 6.19.2
PR-URL: #53468 Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Matthew Aitken <maitken033380023@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent c4a7e05 commit e69b8d2

File tree

11 files changed

+47
-69
lines changed

11 files changed

+47
-69
lines changed
 

‎deps/undici/src/lib/web/fetch/body.js

+10-12
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ function bodyMixinMethods (instance) {
309309
// Return a Blob whose contents are bytes and type attribute
310310
// is mimeType.
311311
return new Blob([bytes], { type: mimeType })
312-
}, instance, false)
312+
}, instance)
313313
},
314314

315315
arrayBuffer () {
@@ -318,21 +318,20 @@ function bodyMixinMethods (instance) {
318318
// given a byte sequence bytes: return a new ArrayBuffer
319319
// whose contents are bytes.
320320
return consumeBody(this, (bytes) => {
321-
// Note: arrayBuffer already cloned.
322-
return bytes.buffer
323-
}, instance, true)
321+
return new Uint8Array(bytes).buffer
322+
}, instance)
324323
},
325324

326325
text () {
327326
// The text() method steps are to return the result of running
328327
// consume body with this and UTF-8 decode.
329-
return consumeBody(this, utf8DecodeBytes, instance, false)
328+
return consumeBody(this, utf8DecodeBytes, instance)
330329
},
331330

332331
json () {
333332
// The json() method steps are to return the result of running
334333
// consume body with this and parse JSON from bytes.
335-
return consumeBody(this, parseJSONFromBytes, instance, false)
334+
return consumeBody(this, parseJSONFromBytes, instance)
336335
},
337336

338337
formData () {
@@ -384,16 +383,16 @@ function bodyMixinMethods (instance) {
384383
throw new TypeError(
385384
'Content-Type was not one of "multipart/form-data" or "application/x-www-form-urlencoded".'
386385
)
387-
}, instance, false)
386+
}, instance)
388387
},
389388

390389
bytes () {
391390
// The bytes() method steps are to return the result of running consume body
392391
// with this and the following step given a byte sequence bytes: return the
393392
// result of creating a Uint8Array from bytes in this’s relevant realm.
394393
return consumeBody(this, (bytes) => {
395-
return new Uint8Array(bytes.buffer, 0, bytes.byteLength)
396-
}, instance, true)
394+
return new Uint8Array(bytes)
395+
}, instance)
397396
}
398397
}
399398

@@ -409,9 +408,8 @@ function mixinBody (prototype) {
409408
* @param {Response|Request} object
410409
* @param {(value: unknown) => unknown} convertBytesToJSValue
411410
* @param {Response|Request} instance
412-
* @param {boolean} [shouldClone]
413411
*/
414-
async function consumeBody (object, convertBytesToJSValue, instance, shouldClone) {
412+
async function consumeBody (object, convertBytesToJSValue, instance) {
415413
webidl.brandCheck(object, instance)
416414

417415
// 1. If object is unusable, then return a promise rejected
@@ -449,7 +447,7 @@ async function consumeBody (object, convertBytesToJSValue, instance, shouldClone
449447

450448
// 6. Otherwise, fully read object’s body given successSteps,
451449
// errorSteps, and object’s relevant global object.
452-
await fullyReadBody(object[kState].body, successSteps, errorSteps, shouldClone)
450+
await fullyReadBody(object[kState].body, successSteps, errorSteps)
453451

454452
// 7. Return promise.
455453
return promise.promise

‎deps/undici/src/lib/web/fetch/util.js

+3-11
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ function iteratorMixin (name, object, kInternalIterator, keyIndex = 0, valueInde
10291029
/**
10301030
* @see https://fetch.spec.whatwg.org/#body-fully-read
10311031
*/
1032-
async function fullyReadBody (body, processBody, processBodyError, shouldClone) {
1032+
async function fullyReadBody (body, processBody, processBodyError) {
10331033
// 1. If taskDestination is null, then set taskDestination to
10341034
// the result of starting a new parallel queue.
10351035

@@ -1055,7 +1055,7 @@ async function fullyReadBody (body, processBody, processBodyError, shouldClone)
10551055

10561056
// 5. Read all bytes from reader, given successSteps and errorSteps.
10571057
try {
1058-
successSteps(await readAllBytes(reader, shouldClone))
1058+
successSteps(await readAllBytes(reader))
10591059
} catch (e) {
10601060
errorSteps(e)
10611061
}
@@ -1103,9 +1103,8 @@ function isomorphicEncode (input) {
11031103
* @see https://streams.spec.whatwg.org/#readablestreamdefaultreader-read-all-bytes
11041104
* @see https://streams.spec.whatwg.org/#read-loop
11051105
* @param {ReadableStreamDefaultReader} reader
1106-
* @param {boolean} [shouldClone]
11071106
*/
1108-
async function readAllBytes (reader, shouldClone) {
1107+
async function readAllBytes (reader) {
11091108
const bytes = []
11101109
let byteLength = 0
11111110

@@ -1114,13 +1113,6 @@ async function readAllBytes (reader, shouldClone) {
11141113

11151114
if (done) {
11161115
// 1. Call successSteps with bytes.
1117-
if (bytes.length === 1) {
1118-
const { buffer, byteOffset, byteLength } = bytes[0]
1119-
if (shouldClone === false) {
1120-
return Buffer.from(buffer, byteOffset, byteLength)
1121-
}
1122-
return Buffer.from(buffer.slice(byteOffset, byteOffset + byteLength), 0, byteLength)
1123-
}
11241116
return Buffer.concat(bytes, byteLength)
11251117
}
11261118

‎deps/undici/src/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎deps/undici/src/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "undici",
3-
"version": "6.19.1",
3+
"version": "6.19.2",
44
"description": "An HTTP/1.1 client, written from scratch for Node.js",
55
"homepage": "https://undici.nodejs.org",
66
"bugs": {
@@ -85,7 +85,7 @@
8585
"test:node-test": "borp -p \"test/node-test/**/*.js\"",
8686
"test:tdd": "borp --expose-gc -p \"test/*.js\"",
8787
"test:tdd:node-test": "borp -p \"test/node-test/**/*.js\" -w",
88-
"test:typescript": "tsd && tsc --skipLibCheck test/imports/undici-import.ts",
88+
"test:typescript": "tsd && tsc test/imports/undici-import.ts --typeRoots ./types && tsc ./types/*.d.ts --noEmit --typeRoots ./types",
8989
"test:webidl": "borp -p \"test/webidl/*.js\"",
9090
"test:websocket": "borp -p \"test/websocket/*.js\"",
9191
"test:websocket:autobahn": "node test/autobahn/client.js",
@@ -99,7 +99,7 @@
9999
"coverage:report:ci": "c8 report",
100100
"bench": "echo \"Error: Benchmarks have been moved to '/benchmarks'\" && exit 1",
101101
"serve:website": "echo \"Error: Documentation has been moved to '/docs'\" && exit 1",
102-
"prepare": "husky install && node ./scripts/platform-shell.js"
102+
"prepare": "husky && node ./scripts/platform-shell.js"
103103
},
104104
"devDependencies": {
105105
"@fastify/busboy": "2.1.1",

‎deps/undici/src/types/formdata.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/// <reference types="node" />
33

44
import { File } from './file'
5-
import { SpecIterator, SpecIterableIterator } from './fetch'
5+
import { SpecIterableIterator } from './fetch'
66

77
/**
88
* A `string` or `File` that represents a single value from a set of `FormData` key-value pairs.

‎deps/undici/src/types/index.d.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ declare namespace Undici {
4242
var RedirectHandler: typeof import ('./handlers').RedirectHandler
4343
var DecoratorHandler: typeof import ('./handlers').DecoratorHandler
4444
var RetryHandler: typeof import ('./retry-handler').default
45-
var createRedirectInterceptor: typeof import ('./interceptors').createRedirectInterceptor
45+
var createRedirectInterceptor: typeof import ('./interceptors').default.createRedirectInterceptor
4646
var BalancedPool: typeof import('./balanced-pool').default;
4747
var Client: typeof import('./client').default;
4848
var buildConnector: typeof import('./connector').default;
@@ -67,9 +67,5 @@ declare namespace Undici {
6767
var File: typeof import('./file').File;
6868
var FileReader: typeof import('./filereader').FileReader;
6969
var caches: typeof import('./cache').caches;
70-
var interceptors: {
71-
dump: typeof import('./interceptors').dump;
72-
retry: typeof import('./interceptors').retry;
73-
redirect: typeof import('./interceptors').redirect;
74-
}
70+
var interceptors: typeof import('./interceptors').default;
7571
}
+11-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import Dispatcher from "./dispatcher";
22
import RetryHandler from "./retry-handler";
33

4-
export type DumpInterceptorOpts = { maxSize?: number }
5-
export type RetryInterceptorOpts = RetryHandler.RetryOptions
6-
export type RedirectInterceptorOpts = { maxRedirections?: number }
4+
export default Interceptors;
75

8-
export declare function createRedirectInterceptor (opts: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
9-
export declare function dump(opts?: DumpInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
10-
export declare function retry(opts?: RetryInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
11-
export declare function redirect(opts?: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
6+
declare namespace Interceptors {
7+
export type DumpInterceptorOpts = { maxSize?: number }
8+
export type RetryInterceptorOpts = RetryHandler.RetryOptions
9+
export type RedirectInterceptorOpts = { maxRedirections?: number }
10+
11+
export function createRedirectInterceptor(opts: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
12+
export function dump(opts?: DumpInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
13+
export function retry(opts?: RetryInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
14+
export function redirect(opts?: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
15+
}

‎deps/undici/src/types/retry-agent.d.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import Agent from './agent'
2-
import buildConnector from './connector';
31
import Dispatcher from './dispatcher'
4-
import { IncomingHttpHeaders } from './header'
52
import RetryHandler from './retry-handler'
63

74
export default RetryAgent

‎deps/undici/src/types/webidl.d.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ interface WebidlUtil {
5555
V: unknown,
5656
bitLength: number,
5757
signedness: 'signed' | 'unsigned',
58-
opts?: ConvertToIntOpts,
59-
prefix: string,
60-
argument: string
58+
opts?: ConvertToIntOpts
6159
): number
6260

6361
/**

‎deps/undici/undici.js

+13-20
Original file line numberDiff line numberDiff line change
@@ -4367,7 +4367,7 @@ var require_util2 = __commonJS({
43674367
});
43684368
}
43694369
__name(iteratorMixin, "iteratorMixin");
4370-
async function fullyReadBody(body, processBody, processBodyError, shouldClone) {
4370+
async function fullyReadBody(body, processBody, processBodyError) {
43714371
const successSteps = processBody;
43724372
const errorSteps = processBodyError;
43734373
let reader;
@@ -4378,7 +4378,7 @@ var require_util2 = __commonJS({
43784378
return;
43794379
}
43804380
try {
4381-
successSteps(await readAllBytes(reader, shouldClone));
4381+
successSteps(await readAllBytes(reader));
43824382
} catch (e) {
43834383
errorSteps(e);
43844384
}
@@ -4405,19 +4405,12 @@ var require_util2 = __commonJS({
44054405
return input;
44064406
}
44074407
__name(isomorphicEncode, "isomorphicEncode");
4408-
async function readAllBytes(reader, shouldClone) {
4408+
async function readAllBytes(reader) {
44094409
const bytes = [];
44104410
let byteLength = 0;
44114411
while (true) {
44124412
const { done, value: chunk } = await reader.read();
44134413
if (done) {
4414-
if (bytes.length === 1) {
4415-
const { buffer, byteOffset, byteLength: byteLength2 } = bytes[0];
4416-
if (shouldClone === false) {
4417-
return Buffer.from(buffer, byteOffset, byteLength2);
4418-
}
4419-
return Buffer.from(buffer.slice(byteOffset, byteOffset + byteLength2), 0, byteLength2);
4420-
}
44214414
return Buffer.concat(bytes, byteLength);
44224415
}
44234416
if (!isUint8Array(chunk)) {
@@ -5393,18 +5386,18 @@ Content-Type: ${value.type || "application/octet-stream"}\r
53935386
mimeType = serializeAMimeType(mimeType);
53945387
}
53955388
return new Blob2([bytes], { type: mimeType });
5396-
}, instance, false);
5389+
}, instance);
53975390
},
53985391
arrayBuffer() {
53995392
return consumeBody(this, (bytes) => {
5400-
return bytes.buffer;
5401-
}, instance, true);
5393+
return new Uint8Array(bytes).buffer;
5394+
}, instance);
54025395
},
54035396
text() {
5404-
return consumeBody(this, utf8DecodeBytes, instance, false);
5397+
return consumeBody(this, utf8DecodeBytes, instance);
54055398
},
54065399
json() {
5407-
return consumeBody(this, parseJSONFromBytes, instance, false);
5400+
return consumeBody(this, parseJSONFromBytes, instance);
54085401
},
54095402
formData() {
54105403
return consumeBody(this, (value) => {
@@ -5433,12 +5426,12 @@ Content-Type: ${value.type || "application/octet-stream"}\r
54335426
throw new TypeError(
54345427
'Content-Type was not one of "multipart/form-data" or "application/x-www-form-urlencoded".'
54355428
);
5436-
}, instance, false);
5429+
}, instance);
54375430
},
54385431
bytes() {
54395432
return consumeBody(this, (bytes) => {
5440-
return new Uint8Array(bytes.buffer, 0, bytes.byteLength);
5441-
}, instance, true);
5433+
return new Uint8Array(bytes);
5434+
}, instance);
54425435
}
54435436
};
54445437
return methods;
@@ -5448,7 +5441,7 @@ Content-Type: ${value.type || "application/octet-stream"}\r
54485441
Object.assign(prototype.prototype, bodyMixinMethods(prototype));
54495442
}
54505443
__name(mixinBody, "mixinBody");
5451-
async function consumeBody(object, convertBytesToJSValue, instance, shouldClone) {
5444+
async function consumeBody(object, convertBytesToJSValue, instance) {
54525445
webidl.brandCheck(object, instance);
54535446
if (bodyUnusable(object[kState].body)) {
54545447
throw new TypeError("Body is unusable: Body has already been read");
@@ -5467,7 +5460,7 @@ Content-Type: ${value.type || "application/octet-stream"}\r
54675460
successSteps(Buffer.allocUnsafe(0));
54685461
return promise.promise;
54695462
}
5470-
await fullyReadBody(object[kState].body, successSteps, errorSteps, shouldClone);
5463+
await fullyReadBody(object[kState].body, successSteps, errorSteps);
54715464
return promise.promise;
54725465
}
54735466
__name(consumeBody, "consumeBody");

‎src/undici_version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
// Refer to tools/dep_updaters/update-undici.sh
33
#ifndef SRC_UNDICI_VERSION_H_
44
#define SRC_UNDICI_VERSION_H_
5-
#define UNDICI_VERSION "6.19.1"
5+
#define UNDICI_VERSION "6.19.2"
66
#endif // SRC_UNDICI_VERSION_H_

0 commit comments

Comments
 (0)