Skip to content

Commit b79c652

Browse files
nodejs-github-botRafaelGSS
authored andcommitted
deps: update undici to 5.23.0
PR-URL: #49021 Reviewed-By: Matthew Aitken <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
1 parent d568600 commit b79c652

18 files changed

+151
-62
lines changed

deps/undici/src/docs/api/ProxyAgent.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ Extends: [`AgentOptions`](Agent.md#parameter-agentoptions)
1919
* **uri** `string` (required) - It can be passed either by a string or a object containing `uri` as string.
2020
* **token** `string` (optional) - It can be passed by a string of token for authentication.
2121
* **auth** `string` (**deprecated**) - Use token.
22-
* **clientFactory** `(origin: URL, opts: Object) => Dispatcher` - Default: `(origin, opts) => new Pool(origin, opts)`
22+
* **clientFactory** `(origin: URL, opts: Object) => Dispatcher` (optional) - Default: `(origin, opts) => new Pool(origin, opts)`
23+
* **requestTls** `BuildOptions` (optional) - Options object passed when creating the underlying socket via the connector builder for the request. See [TLS](https://nodejs.org/api/tls.html#tlsconnectoptions-callback).
24+
* **proxyTls** `BuildOptions` (optional) - Options object passed when creating the underlying socket via the connector builder for the proxy server. See [TLS](https://nodejs.org/api/tls.html#tlsconnectoptions-callback).
2325

2426
Examples:
2527

deps/undici/src/lib/api/abort-signal.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { addAbortListener } = require('../core/util')
12
const { RequestAbortedError } = require('../core/errors')
23

34
const kListener = Symbol('kListener')
@@ -29,11 +30,7 @@ function addSignal (self, signal) {
2930
abort(self)
3031
}
3132

32-
if ('addEventListener' in self[kSignal]) {
33-
self[kSignal].addEventListener('abort', self[kListener])
34-
} else {
35-
self[kSignal].addListener('abort', self[kListener])
36-
}
33+
addAbortListener(self[kSignal], self[kListener])
3734
}
3835

3936
function removeSignal (self) {

deps/undici/src/lib/api/readable.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,13 @@ module.exports = class BodyReadable extends Readable {
155155
const abortFn = () => {
156156
this.destroy()
157157
}
158+
let signalListenerCleanup
158159
if (signal) {
159160
if (typeof signal !== 'object' || !('aborted' in signal)) {
160161
throw new InvalidArgumentError('signal must be an AbortSignal')
161162
}
162163
util.throwIfAborted(signal)
163-
signal.addEventListener('abort', abortFn, { once: true })
164+
signalListenerCleanup = util.addAbortListener(signal, abortFn)
164165
}
165166
try {
166167
for await (const chunk of this) {
@@ -173,8 +174,10 @@ module.exports = class BodyReadable extends Readable {
173174
} catch {
174175
util.throwIfAborted(signal)
175176
} finally {
176-
if (signal) {
177-
signal.removeEventListener('abort', abortFn)
177+
if (typeof signalListenerCleanup === 'function') {
178+
signalListenerCleanup()
179+
} else if (signalListenerCleanup) {
180+
signalListenerCleanup[Symbol.dispose]()
178181
}
179182
}
180183
}

deps/undici/src/lib/core/util.js

+19
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,24 @@ function throwIfAborted (signal) {
422422
}
423423
}
424424

425+
let events
426+
function addAbortListener (signal, listener) {
427+
if (typeof Symbol.dispose === 'symbol') {
428+
if (!events) {
429+
events = require('events')
430+
}
431+
if (typeof events.addAbortListener === 'function' && 'aborted' in signal) {
432+
return events.addAbortListener(signal, listener)
433+
}
434+
}
435+
if ('addEventListener' in signal) {
436+
signal.addEventListener('abort', listener, { once: true })
437+
return () => signal.removeEventListener('abort', listener)
438+
}
439+
signal.addListener('abort', listener)
440+
return () => signal.removeListener('abort', listener)
441+
}
442+
425443
const hasToWellFormed = !!String.prototype.toWellFormed
426444

427445
/**
@@ -469,6 +487,7 @@ module.exports = {
469487
isFormDataLike,
470488
buildURL,
471489
throwIfAborted,
490+
addAbortListener,
472491
nodeMajor,
473492
nodeMinor,
474493
nodeHasAutoSelectFamily: nodeMajor > 18 || (nodeMajor === 18 && nodeMinor >= 13)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function extractBody (object, keepalive = false) {
105105
// Set source to a copy of the bytes held by object.
106106
source = new Uint8Array(object.buffer.slice(object.byteOffset, object.byteOffset + object.byteLength))
107107
} else if (util.isFormDataLike(object)) {
108-
const boundary = `----formdata-undici-${Math.random()}`.replace('.', '').slice(0, 32)
108+
const boundary = `----formdata-undici-0${`${Math.floor(Math.random() * 1e11)}`.padStart(11, '0')}`
109109
const prefix = `--${boundary}\r\nContent-Disposition: form-data`
110110

111111
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */

deps/undici/src/lib/fetch/index.js

+21-14
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const {
5656
const { kHeadersList } = require('../core/symbols')
5757
const EE = require('events')
5858
const { Readable, pipeline } = require('stream')
59-
const { isErrored, isReadable, nodeMajor, nodeMinor } = require('../core/util')
59+
const { addAbortListener, isErrored, isReadable, nodeMajor, nodeMinor } = require('../core/util')
6060
const { dataURLProcessor, serializeAMimeType } = require('./dataURL')
6161
const { TransformStream } = require('stream/web')
6262
const { getGlobalDispatcher } = require('../global')
@@ -174,22 +174,22 @@ async function fetch (input, init = {}) {
174174
let controller = null
175175

176176
// 11. Add the following abort steps to requestObject’s signal:
177-
requestObject.signal.addEventListener(
178-
'abort',
177+
addAbortListener(
178+
requestObject.signal,
179179
() => {
180180
// 1. Set locallyAborted to true.
181181
locallyAborted = true
182182

183-
// 2. Abort the fetch() call with p, request, responseObject,
183+
// 2. Assert: controller is non-null.
184+
assert(controller != null)
185+
186+
// 3. Abort controller with requestObject’s signal’s abort reason.
187+
controller.abort(requestObject.signal.reason)
188+
189+
// 4. Abort the fetch() call with p, request, responseObject,
184190
// and requestObject’s signal’s abort reason.
185191
abortFetch(p, request, responseObject, requestObject.signal.reason)
186-
187-
// 3. If controller is not null, then abort controller.
188-
if (controller != null) {
189-
controller.abort()
190-
}
191-
},
192-
{ once: true }
192+
}
193193
)
194194

195195
// 12. Let handleFetchDone given response response be to finalize and
@@ -319,7 +319,7 @@ function finalizeAndReportTiming (response, initiatorType = 'other') {
319319
// https://w3c.github.io/resource-timing/#dfn-mark-resource-timing
320320
function markResourceTiming (timingInfo, originalURL, initiatorType, globalThis, cacheState) {
321321
if (nodeMajor > 18 || (nodeMajor === 18 && nodeMinor >= 2)) {
322-
performance.markResourceTiming(timingInfo, originalURL, initiatorType, globalThis, cacheState)
322+
performance.markResourceTiming(timingInfo, originalURL.href, initiatorType, globalThis, cacheState)
323323
}
324324
}
325325

@@ -1986,7 +1986,7 @@ async function httpNetworkFetch (
19861986
if (key.toLowerCase() === 'content-encoding') {
19871987
// https://www.rfc-editor.org/rfc/rfc7231#section-3.1.2.1
19881988
// "All content-coding values are case-insensitive..."
1989-
codings = val.toLowerCase().split(',').map((x) => x.trim())
1989+
codings = val.toLowerCase().split(',').map((x) => x.trim()).reverse()
19901990
} else if (key.toLowerCase() === 'location') {
19911991
location = val
19921992
}
@@ -2007,7 +2007,14 @@ async function httpNetworkFetch (
20072007
for (const coding of codings) {
20082008
// https://www.rfc-editor.org/rfc/rfc9112.html#section-7.2
20092009
if (coding === 'x-gzip' || coding === 'gzip') {
2010-
decoders.push(zlib.createGunzip())
2010+
decoders.push(zlib.createGunzip({
2011+
// Be less strict when decoding compressed responses, since sometimes
2012+
// servers send slightly invalid responses that are still accepted
2013+
// by common browsers.
2014+
// Always using Z_SYNC_FLUSH is what cURL does.
2015+
flush: zlib.constants.Z_SYNC_FLUSH,
2016+
finishFlush: zlib.constants.Z_SYNC_FLUSH
2017+
}))
20112018
} else if (coding === 'deflate') {
20122019
decoders.push(zlib.createInflate())
20132020
} else if (coding === 'br') {

deps/undici/src/lib/fetch/request.js

+17-12
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,18 @@ class Request {
232232
}
233233

234234
// 3. If one of the following is true
235-
// parsedReferrer’s cannot-be-a-base-URL is true, scheme is "about",
236-
// and path contains a single string "client"
237-
// parsedReferrer’s origin is not same origin with origin
235+
// - parsedReferrer’s scheme is "about" and path is the string "client"
236+
// - parsedReferrer’s origin is not same origin with origin
238237
// then set request’s referrer to "client".
239-
// TODO
240-
241-
// 4. Otherwise, set request’s referrer to parsedReferrer.
242-
request.referrer = parsedReferrer
238+
if (
239+
(parsedReferrer.protocol === 'about:' && parsedReferrer.hostname === 'client') ||
240+
(origin && !sameOrigin(parsedReferrer, this[kRealm].settingsObject.baseUrl))
241+
) {
242+
request.referrer = 'client'
243+
} else {
244+
// 4. Otherwise, set request’s referrer to parsedReferrer.
245+
request.referrer = parsedReferrer
246+
}
243247
}
244248
}
245249

@@ -336,6 +340,8 @@ class Request {
336340

337341
// 28. Set this’s signal to a new AbortSignal object with this’s relevant
338342
// Realm.
343+
// TODO: could this be simplified with AbortSignal.any
344+
// (https://dom.spec.whatwg.org/#dom-abortsignal-any)
339345
const ac = new AbortController()
340346
this[kSignal] = ac.signal
341347
this[kSignal][kRealm] = this[kRealm]
@@ -381,7 +387,7 @@ class Request {
381387
}
382388
} catch {}
383389

384-
signal.addEventListener('abort', abort, { once: true })
390+
util.addAbortListener(signal, abort)
385391
requestFinalizer.register(ac, { signal, abort })
386392
}
387393
}
@@ -729,12 +735,11 @@ class Request {
729735
if (this.signal.aborted) {
730736
ac.abort(this.signal.reason)
731737
} else {
732-
this.signal.addEventListener(
733-
'abort',
738+
util.addAbortListener(
739+
this.signal,
734740
() => {
735741
ac.abort(this.signal.reason)
736-
},
737-
{ once: true }
742+
}
738743
)
739744
}
740745
clonedRequestObject[kSignal] = ac.signal

deps/undici/src/lib/llhttp/llhttp-wasm.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
-535 Bytes
Binary file not shown.

deps/undici/src/lib/llhttp/llhttp_simd-wasm.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
-535 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
alpine-baselayout-data-3.4.0-r0
2+
musl-1.2.3-r4
3+
busybox-1.35.0-r29
4+
busybox-binsh-1.35.0-r29
5+
alpine-baselayout-3.4.0-r0
6+
alpine-keys-2.4-r1
7+
ca-certificates-bundle-20220614-r4
8+
libcrypto3-3.0.8-r3
9+
libssl3-3.0.8-r3
10+
ssl_client-1.35.0-r29
11+
zlib-1.2.13-r0
12+
apk-tools-2.12.10-r1
13+
scanelf-1.3.5-r1
14+
musl-utils-1.2.3-r4
15+
libc-utils-0.7.2-r3
16+
libgcc-12.2.1_git20220924-r4
17+
libstdc++-12.2.1_git20220924-r4
18+
libffi-3.4.4-r0
19+
xz-libs-5.2.9-r0
20+
libxml2-2.10.4-r0
21+
zstd-libs-1.5.5-r0
22+
llvm15-libs-15.0.7-r0
23+
clang15-libs-15.0.7-r0
24+
libstdc++-dev-12.2.1_git20220924-r4
25+
clang15-15.0.7-r0
26+
lld-libs-15.0.7-r0
27+
lld-15.0.7-r0
28+
wasi-libc-0.20220525-r1
29+
wasi-libcxx-15.0.7-r0
30+
wasi-libcxxabi-15.0.7-r0
31+
wasi-compiler-rt-15.0.7-r0
32+
wasi-sdk-16-r0

deps/undici/src/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "undici",
3-
"version": "5.22.1",
3+
"version": "5.23.0",
44
"description": "An HTTP/1.1 client, written from scratch for Node.js",
55
"homepage": "https://undici.nodejs.org",
66
"bugs": {
@@ -86,7 +86,7 @@
8686
"husky": "^8.0.1",
8787
"import-fresh": "^3.3.0",
8888
"jest": "^29.0.2",
89-
"jsdom": "^21.1.0",
89+
"jsdom": "^22.1.0",
9090
"jsfuzz": "^1.0.15",
9191
"mocha": "^10.0.0",
9292
"p-timeout": "^3.2.0",

deps/undici/src/types/dispatcher.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ declare namespace Dispatcher {
229229
arrayBuffer(): Promise<ArrayBuffer>;
230230
blob(): Promise<Blob>;
231231
formData(): Promise<never>;
232-
json(): Promise<any>;
232+
json(): Promise<unknown>;
233233
text(): Promise<string>;
234234
}
235235

deps/undici/src/types/readable.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ declare class BodyReadable extends Readable {
1818
/** Consumes and returns the body as a JavaScript Object
1919
* https://fetch.spec.whatwg.org/#dom-body-json
2020
*/
21-
json(): Promise<any>
21+
json(): Promise<unknown>
2222

2323
/** Consumes and returns the body as a Blob
2424
* https://fetch.spec.whatwg.org/#dom-body-blob

deps/undici/undici.js

+40-16
Large diffs are not rendered by default.

doc/contributing/maintaining/maintaining-dependencies.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This a list of all the dependencies:
2828
* [openssl 3.0.8][]
2929
* [postject 1.0.0-alpha.6][]
3030
* [simdutf 3.2.14][]
31-
* [undici 5.22.1][]
31+
* [undici 5.23.0][]
3232
* [uvwasi 0.0.16][]
3333
* [V8 11.3.244.8][]
3434
* [zlib 1.2.13.1-motley-61dc0bd][]
@@ -291,7 +291,7 @@ The [postject](https://github.com/nodejs/postject) dependency is used for the
291291
The [simdutf](https://github.com/simdutf/simdutf) dependency is
292292
a C++ library for fast UTF-8 decoding and encoding.
293293

294-
### undici 5.22.1
294+
### undici 5.23.0
295295

296296
The [undici](https://github.com/nodejs/undici) dependency is an HTTP/1.1 client,
297297
written from scratch for Node.js..
@@ -345,7 +345,7 @@ performance improvements not currently available in standard zlib.
345345
[openssl 3.0.8]: #openssl-308
346346
[postject 1.0.0-alpha.6]: #postject-100-alpha6
347347
[simdutf 3.2.14]: #simdutf-3214
348-
[undici 5.22.1]: #undici-5221
348+
[undici 5.23.0]: #undici-5230
349349
[update-openssl-action]: ../../../.github/workflows/update-openssl.yml
350350
[uvwasi 0.0.16]: #uvwasi-0016
351351
[v8 11.3.244.8]: #v8-1132448

src/undici_version.h

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

0 commit comments

Comments
 (0)