Skip to content

Commit 8c71740

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update undici to 7.21.0
PR-URL: #61683 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
1 parent 7643bc8 commit 8c71740

27 files changed

+554
-274
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Returns: `Client`
3434
* **maxConcurrentStreams**: `number` - Default: `100`. Dictates the maximum number of concurrent streams for a single H2 session. It can be overridden by a SETTINGS remote frame.
3535
* **initialWindowSize**: `number` (optional) - Default: `262144` (256KB). Sets the HTTP/2 stream-level flow-control window size (SETTINGS_INITIAL_WINDOW_SIZE). Must be a positive integer greater than 0. This default is higher than Node.js core's default (65535 bytes) to improve throughput, Node's choice is very conservative for current high-bandwith networks. See [RFC 7540 Section 6.9.2](https://datatracker.ietf.org/doc/html/rfc7540#section-6.9.2) for more details.
3636
* **connectionWindowSize**: `number` (optional) - Default `524288` (512KB). Sets the HTTP/2 connection-level flow-control window size using `ClientHttp2Session.setLocalWindowSize()`. Must be a positive integer greater than 0. This provides better flow control for the entire connection across multiple streams. See [Node.js HTTP/2 documentation](https://nodejs.org/api/http2.html#clienthttp2sessionsetlocalwindowsize) for more details.
37+
* **pingInterval**: `number` - Default: `60e3`. The time interval in milliseconds between PING frames sent to the server. Set to `0` to disable PING frames. This is only applicable for HTTP/2 connections. This will emit a `ping` event on the client with the duration of the ping in milliseconds.
3738

3839
> **Notes about HTTP/2**
3940
> - It only works under TLS connections. h2c is not supported.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ The `RequestOptions.method` property should not be value `'CONNECT'`.
476476
#### Parameter: `ResponseData`
477477

478478
* **statusCode** `number`
479+
* **statusText** `string` - The status message from the response (e.g., "OK", "Not Found").
479480
* **headers** `Record<string, string | string[]>` - Note that all header keys are lower-cased, e.g. `content-type`.
480481
* **body** `stream.Readable` which also implements [the body mixin from the Fetch Standard](https://fetch.spec.whatwg.org/#body-mixin).
481482
* **trailers** `Record<string, string>` - This object starts out
@@ -517,7 +518,7 @@ await once(server, 'listening')
517518
const client = new Client(`http://localhost:${server.address().port}`)
518519

519520
try {
520-
const { body, headers, statusCode, trailers } = await client.request({
521+
const { body, headers, statusCode, statusText, trailers } = await client.request({
521522
path: '/',
522523
method: 'GET'
523524
})

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Returns: `H2CClient`
4848
- **maxResponseSize** `number | null` (optional) - Default: `-1` - The maximum length of response body in bytes. Set to `-1` to disable.
4949
- **maxConcurrentStreams**: `number` - Default: `100`. Dictates the maximum number of concurrent streams for a single H2 session. It can be overridden by a SETTINGS remote frame.
5050
- **pipelining** `number | null` (optional) - Default to `maxConcurrentStreams` - The amount of concurrent requests sent over a single HTTP/2 session in accordance with [RFC-7540](https://httpwg.org/specs/rfc7540.html#StreamsLayer) Stream specification. Streams can be closed up by remote server at any time.
51+
- **pingInterval**: `number` - Default: `60e3`. The time interval in milliseconds between PING frames sent to the server. Set to `0` to disable PING frames. This is only applicable for HTTP/2 connections.
5152
- **connect** `ConnectOptions | null` (optional) - Default: `null`.
5253
- **strictContentLength** `Boolean` (optional) - Default: `true` - Whether to treat request content length mismatches as errors. If true, an error is thrown when the request content-length header doesn't match the length of the request body. **Security Warning:** Disabling this option can expose your application to HTTP Request Smuggling attacks, where mismatched content-length headers cause servers and proxies to interpret request boundaries differently. This can lead to cache poisoning, credential hijacking, and bypassing security controls. Only disable this in controlled environments where you fully trust the request source.
5354
- **autoSelectFamily**: `boolean` (optional) - Default: depends on local Node version, on Node 18.13.0 and above is `false`. Enables a family autodetection algorithm that loosely implements section 5 of [RFC 8305](https://tools.ietf.org/html/rfc8305#section-5). See [here](https://nodejs.org/api/net.html#socketconnectoptions-connectlistener) for more details. This option is ignored if not supported by the current Node version.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@ try {
323323
method: 'GET'
324324
})
325325
} catch (error) {
326-
console.error(error) // Error: kaboom
326+
console.error(error) // TypeError: fetch failed
327+
console.error(error.cause) // Error: kaboom
327328
}
328329
```
329330

deps/undici/src/index-fetch.js

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,40 @@ const { getGlobalDispatcher, setGlobalDispatcher } = require('./lib/global')
44
const EnvHttpProxyAgent = require('./lib/dispatcher/env-http-proxy-agent')
55
const fetchImpl = require('./lib/web/fetch').fetch
66

7+
// Capture __filename at module load time for stack trace augmentation.
8+
// This may be undefined when bundled in environments like Node.js internals.
9+
const currentFilename = typeof __filename !== 'undefined' ? __filename : undefined
10+
11+
function appendFetchStackTrace (err, filename) {
12+
if (!err || typeof err !== 'object') {
13+
return
14+
}
15+
16+
const stack = typeof err.stack === 'string' ? err.stack : ''
17+
const normalizedFilename = filename.replace(/\\/g, '/')
18+
19+
if (stack && (stack.includes(filename) || stack.includes(normalizedFilename))) {
20+
return
21+
}
22+
23+
const capture = {}
24+
Error.captureStackTrace(capture, appendFetchStackTrace)
25+
26+
if (!capture.stack) {
27+
return
28+
}
29+
30+
const captureLines = capture.stack.split('\n').slice(1).join('\n')
31+
32+
err.stack = stack ? `${stack}\n${captureLines}` : capture.stack
33+
}
34+
735
module.exports.fetch = function fetch (init, options = undefined) {
836
return fetchImpl(init, options).catch(err => {
9-
if (err && typeof err === 'object') {
10-
Error.captureStackTrace(err)
37+
if (currentFilename) {
38+
appendFetchStackTrace(err, currentFilename)
39+
} else if (err && typeof err === 'object') {
40+
Error.captureStackTrace(err, module.exports.fetch)
1141
}
1242
throw err
1343
})

deps/undici/src/index.js

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,40 @@ module.exports.getGlobalDispatcher = getGlobalDispatcher
121121

122122
const fetchImpl = require('./lib/web/fetch').fetch
123123

124+
// Capture __filename at module load time for stack trace augmentation.
125+
// This may be undefined when bundled in environments like Node.js internals.
126+
const currentFilename = typeof __filename !== 'undefined' ? __filename : undefined
127+
128+
function appendFetchStackTrace (err, filename) {
129+
if (!err || typeof err !== 'object') {
130+
return
131+
}
132+
133+
const stack = typeof err.stack === 'string' ? err.stack : ''
134+
const normalizedFilename = filename.replace(/\\/g, '/')
135+
136+
if (stack && (stack.includes(filename) || stack.includes(normalizedFilename))) {
137+
return
138+
}
139+
140+
const capture = {}
141+
Error.captureStackTrace(capture, appendFetchStackTrace)
142+
143+
if (!capture.stack) {
144+
return
145+
}
146+
147+
const captureLines = capture.stack.split('\n').slice(1).join('\n')
148+
149+
err.stack = stack ? `${stack}\n${captureLines}` : capture.stack
150+
}
151+
124152
module.exports.fetch = function fetch (init, options = undefined) {
125153
return fetchImpl(init, options).catch(err => {
126-
if (err && typeof err === 'object') {
127-
Error.captureStackTrace(err)
154+
if (currentFilename) {
155+
appendFetchStackTrace(err, currentFilename)
156+
} else if (err && typeof err === 'object') {
157+
Error.captureStackTrace(err, module.exports.fetch)
128158
}
129159
throw err
130160
})

deps/undici/src/lib/api/api-request.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ class RequestHandler extends AsyncResource {
121121
try {
122122
this.runInAsyncScope(callback, null, null, {
123123
statusCode,
124+
statusText: statusMessage,
124125
headers,
125126
trailers: this.trailers,
126127
opaque,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ module.exports = {
6767
kEnableConnectProtocol: Symbol('http2session connect protocol'),
6868
kRemoteSettings: Symbol('http2session remote settings'),
6969
kHTTP2Stream: Symbol('http2session client stream'),
70+
kPingInterval: Symbol('ping interval'),
7071
kNoProxyAgent: Symbol('no proxy agent'),
7172
kHttpProxyAgent: Symbol('http proxy agent'),
7273
kHttpsProxyAgent: Symbol('https proxy agent')

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ class Agent extends DispatcherBase {
9292
if (connected) result.count -= 1
9393
if (result.count <= 0) {
9494
this[kClients].delete(key)
95-
result.dispatcher.close()
95+
if (!result.dispatcher.destroyed) {
96+
result.dispatcher.close()
97+
}
9698
}
9799
this[kOrigins].delete(key)
98100
}

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,8 +735,13 @@ class Parser {
735735
}
736736
}
737737

738-
function onParserTimeout (parser) {
739-
const { socket, timeoutType, client, paused } = parser.deref()
738+
function onParserTimeout (parserWeakRef) {
739+
const parser = parserWeakRef.deref()
740+
if (!parser) {
741+
return
742+
}
743+
744+
const { socket, timeoutType, client, paused } = parser
740745

741746
if (timeoutType === TIMEOUT_HEADERS) {
742747
if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) {

0 commit comments

Comments
 (0)