Skip to content

Commit 2a7f501

Browse files
nodejs-github-botmcollina
authored andcommitted
deps: update undici to 8.10.2
1 parent 1e9fd95 commit 2a7f501

52 files changed

Lines changed: 2672 additions & 1302 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ added: v1.0.0
147147
WebSocket messages. Applied to uncompressed messages, compressed frame
148148
payloads, and decompressed (`permessage-deflate`) messages. Set to `0` to
149149
disable the limit. **Default:** `134217728`.
150+
* `eventSource` {Object} (optional) EventSource-specific configuration.
151+
* `maxEventSize` {number} The maximum allowed event size, in bytes, for
152+
EventSource messages. Set to `0` to disable the limit.
153+
**Default:** `buffer.kStringMaxLength`.
150154
* Returns: {Client}
151155

152156
Instantiating a `Client` does not open a connection; the connection is

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ it is used only for HTTPS requests.
2525
proxied. Each entry may include a leading dot or `*.` wildcard (for example
2626
`.example.com`) to match subdomains, and an optional `:port` suffix to restrict
2727
the match to a specific port. A request bypasses the proxy when its host equals
28-
an entry or is a subdomain of one. Setting `no_proxy` to `*` bypasses the proxy
29-
for every request.
28+
an entry or is a subdomain of one. A trailing dot is ignored on both sides, so
29+
`example.com.` and `example.com` match each other. Setting `no_proxy` to `*`
30+
bypasses the proxy for every request.
3031

3132
The uppercase variants `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` are also
3233
honored. When both the lowercase and uppercase forms of a variable are set, the

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ added: v6.5.0
6666
wait before re-establishing a dropped connection. The server may override
6767
this value with a `retry` field. **Default:** `3000`.
6868

69+
EventSource-specific limits can be configured on the dispatcher using the
70+
`eventSource` option. See [`Client`][] for details.
71+
6972
Creates a new `EventSource` and immediately begins connecting to `url`. The
7073
request is sent with the `Accept: text/event-stream` header, a cache mode of
7174
`no-store`, and an initiator type of `other`.
@@ -349,6 +352,7 @@ eventSource.onerror = () => {
349352
```
350353

351354
[WHATWG-conformant]: https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events
355+
[`Client`]: Client.md#new-clienturl-options
352356
[`Dispatcher`]: Dispatcher.md#class-dispatcher
353357
[`addEventListener()`]: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
354358
[server-sent events]: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ body yourself.
101101
102102
* `opts` {Object} (optional)
103103
* `maxSize` {number} Maximum number of bytes to read and discard. Responses
104-
whose `Content-Length` exceeds this value are aborted. **Default:**
105-
`1_048_576` (1 MiB).
104+
whose declared or received body size exceeds this value are aborted.
105+
**Default:** `1_048_576` (1 MiB).
106106
107107
Per-request override: set `dumpMaxSize` on the dispatch options to override
108108
the global `maxSize` for a specific request.
@@ -210,6 +210,9 @@ Automatically decompresses response bodies encoded with `gzip`, `x-gzip`,
210210
skipped. **Default:** `[204, 304]`.
211211
* `skipErrorResponses` {boolean} When `true`, responses with a status code
212212
>= 400 are not decompressed. **Default:** `true`.
213+
* `maxSize` {number} Maximum decompressed response size in bytes. The request
214+
fails with a `ResponseExceededMaxSizeError` if the decoded body exceeds
215+
this limit. **Default:** `67108864` (64 MiB).
213216
214217
**Returns:** {Dispatcher.DispatcherComposeInterceptor}
215218
@@ -221,7 +224,8 @@ import { Agent, interceptors } from 'undici'
221224
const agent = new Agent().compose(
222225
interceptors.decompress({
223226
skipStatusCodes: [204, 304],
224-
skipErrorResponses: false // decompress error bodies too
227+
skipErrorResponses: false, // decompress error bodies too
228+
maxSize: 16 * 1024 * 1024 // limit decoded bodies to 16 MiB
225229
})
226230
)
227231
```

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ added: v7.23.0
6060
a password embedded in `proxyUrl`. **Default:** the URL password, if any.
6161
* `connect` {Function} Custom connector used to open the socket to the proxy.
6262
**Default:** a connector built from `proxyTls`.
63+
* `connectTimeout` {number} Maximum time in milliseconds for each proxy
64+
connection, SOCKS5 negotiation, and target TLS negotiation stage. A value of
65+
`0` disables these stage timeouts. `proxyTls.timeout` and
66+
`requestTls.timeout` override it for their respective TLS stages.
67+
**Default:** `5000`.
6368
* `proxyTls` {BuildOptions} TLS options for the connection to the proxy itself
6469
(SOCKS5 over TLS). When set, the proxy connection is established over TLS and
6570
`servername` defaults to the proxy host name.
@@ -69,7 +74,8 @@ added: v7.23.0
6974
host name.
7075

7176
Throws an `InvalidArgumentError` if `proxyUrl` is missing or does not use the
72-
`socks5:` or `socks:` protocol.
77+
`socks5:` or `socks:` protocol, or if `connectTimeout`, `proxyTls.timeout`, or
78+
`requestTls.timeout` is not a finite, non-negative number.
7379

7480
```mjs
7581
import { Socks5ProxyAgent } from 'undici'

deps/undici/src/lib/cache/memory-cache-store.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class MemoryCacheStore extends EventEmitter {
8787
}
8888

8989
/**
90-
* @param {import('../../types/cache-interceptor.d.ts').default.CacheKey} req
90+
* @param {import('../../types/cache-interceptor.d.ts').default.CacheKey} key
9191
* @returns {import('../../types/cache-interceptor.d.ts').default.GetResult | undefined}
9292
*/
9393
get (key) {
@@ -179,7 +179,7 @@ class MemoryCacheStore extends EventEmitter {
179179

180180
// Perform eviction
181181
for (const [key, entries] of store.#entries) {
182-
for (const entry of entries.splice(0, entries.length / 2)) {
182+
for (const entry of entries.splice(0, Math.ceil(entries.length / 2))) {
183183
store.#size -= entry.size
184184
store.#count -= 1
185185
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ module.exports = {
55
kDestroy: Symbol('destroy'),
66
kDispatch: Symbol('dispatch'),
77
kUrl: Symbol('url'),
8+
kRequestOrigin: Symbol('request origin'),
9+
kOriginless: Symbol('originless'),
810
kWriting: Symbol('writing'),
911
kResuming: Symbol('resuming'),
1012
kQueue: Symbol('queue'),

deps/undici/src/lib/dispatcher/agent.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
const { InvalidArgumentError, MaxOriginsReachedError } = require('../core/errors')
4-
const { kBusy, kClients, kConnected, kRunning, kClose, kDestroy, kDispatch, kUrl } = require('../core/symbols')
4+
const { kBusy, kClients, kConnected, kRunning, kPending, kClose, kDestroy, kDispatch, kUrl } = require('../core/symbols')
55
const DispatcherBase = require('./dispatcher-base')
66
const Pool = require('./pool')
77
const Client = require('./client')
@@ -97,7 +97,12 @@ class Agent extends DispatcherBase {
9797
return
9898
}
9999

100-
if (dispatcher[kConnected] > 0 || dispatcher[kBusy]) {
100+
// A GOAWAY detaches the HTTP/2 session before requeued requests are
101+
// dispatched on a replacement connection. At that point the pool has
102+
// no connected clients and is not busy, but it still has pending work.
103+
// Closing it here lets the replacement Client finish those requests
104+
// and then destroys that new connection with ClientDestroyedError.
105+
if (dispatcher[kConnected] > 0 || dispatcher[kBusy] || dispatcher[kPending] > 0) {
101106
return
102107
}
103108

deps/undici/src/lib/dispatcher/balanced-pool.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const {
1313
kGetDispatcher
1414
} = require('./pool-base')
1515
const Pool = require('./pool')
16-
const { kUrl } = require('../core/symbols')
16+
const { kOriginless, kUrl } = require('../core/symbols')
1717
const util = require('../core/util')
1818
const kFactory = Symbol('factory')
1919

@@ -49,14 +49,17 @@ function defaultFactory (origin, opts) {
4949
}
5050

5151
class BalancedPool extends PoolBase {
52-
constructor (upstreams = [], { factory = defaultFactory, ...opts } = {}) {
52+
constructor (upstreams = [], { factory = defaultFactory, connect, tls, ...opts } = {}) {
5353
if (typeof factory !== 'function') {
5454
throw new InvalidArgumentError('factory must be a function.')
5555
}
5656

57-
super()
57+
super(opts)
5858

59-
this[kOptions] = { ...util.deepClone(opts) }
59+
this[kOriginless] = true
60+
if (connect && typeof connect !== 'function') connect = { ...connect }
61+
if (tls && typeof tls !== 'function') tls = { ...tls }
62+
this[kOptions] = { ...util.deepClone(opts), connect, tls }
6063
this[kIndex] = -1
6164
this[kCurrentWeight] = 0
6265

deps/undici/src/lib/dispatcher/client-h1.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ function onSocketClose () {
10521052

10531053
function clearIdleSocketValidation (socket) {
10541054
if (socket[kIdleSocketValidationTimeout]) {
1055-
clearTimeout(socket[kIdleSocketValidationTimeout])
1055+
clearImmediate(socket[kIdleSocketValidationTimeout])
10561056
socket[kIdleSocketValidationTimeout] = null
10571057
}
10581058

@@ -1061,15 +1061,23 @@ function clearIdleSocketValidation (socket) {
10611061

10621062
function scheduleIdleSocketValidation (client, socket) {
10631063
socket[kIdleSocketValidation] = 1
1064-
socket[kIdleSocketValidationTimeout] = setTimeout(() => {
1064+
// Yield to the check phase (after poll) so unsolicited bytes / FIN / RST
1065+
// already pending on this idle keep-alive socket are processed before the
1066+
// next request is written (GHSA-35p6-xmwp-9g52).
1067+
//
1068+
// setTimeout(0) pays Node's ~1ms timer floor on every sequential reuse
1069+
// (#5493). setImmediate avoids that, but an *unref'd* Immediate lets poll
1070+
// block for ~500ms when the event loop is otherwise idle (#5600 / #5606).
1071+
// A ref'd Immediate both keeps the pending request alive and makes poll
1072+
// return immediately — the hybrid those issues asked for.
1073+
socket[kIdleSocketValidationTimeout] = setImmediate(() => {
10651074
socket[kIdleSocketValidationTimeout] = null
10661075
socket[kIdleSocketValidation] = 2
10671076

10681077
if (client[kSocket] === socket && !socket.destroyed) {
10691078
client[kResume]()
10701079
}
1071-
}, 0)
1072-
socket[kIdleSocketValidationTimeout].unref?.()
1080+
})
10731081
}
10741082

10751083
/**

0 commit comments

Comments
 (0)