Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: update undici to 5.26.4 #50272

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deps/undici/src/docs/api/Client.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Returns: `Client`
* **keepAliveMaxTimeout** `number | null` (optional) - Default: `600e3` - The maximum allowed `keepAliveTimeout`, in milliseconds, when overridden by *keep-alive* hints from the server. Defaults to 10 minutes.
* **keepAliveTimeout** `number | null` (optional) - Default: `4e3` - The timeout, in milliseconds, after which a socket without active requests will time out. Monitors time between activity on a connected socket. This value may be overridden by *keep-alive* hints from the server. See [MDN: HTTP - Headers - Keep-Alive directives](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive#directives) for more details. Defaults to 4 seconds.
* **keepAliveTimeoutThreshold** `number | null` (optional) - Default: `1e3` - A number of milliseconds subtracted from server *keep-alive* hints when overriding `keepAliveTimeout` to account for timing inaccuracies caused by e.g. transport latency. Defaults to 1 second.
* **maxHeaderSize** `number | null` (optional) - Default: `16384` - The maximum length of request headers in bytes. Defaults to 16KiB.
* **maxHeaderSize** `number | null` (optional) - Default: `--max-http-header-size` or `16384` - The maximum length of request headers in bytes. Defaults to Node.js' --max-http-header-size or 16KiB.
* **maxResponseSize** `number | null` (optional) - Default: `-1` - The maximum length of response body in bytes. Set to `-1` to disable.
* **pipelining** `number | null` (optional) - Default: `1` - The amount of concurrent requests to be sent over the single TCP/TLS connection according to [RFC7230](https://tools.ietf.org/html/rfc7230#section-6.3.2). Carefully consider your workload and environment before enabling concurrent requests as pipelining may reduce performance if used incorrectly. Pipelining is sensitive to network stack settings as well as head of line blocking caused by e.g. long running requests. Set to `0` to disable keep-alive connections.
* **connect** `ConnectOptions | Function | null` (optional) - Default: `null`.
Expand Down
2 changes: 1 addition & 1 deletion deps/undici/src/docs/api/DispatchInterceptor.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Interface: DispatchInterceptor
# Interface: DispatchInterceptor

Extends: `Function`

Expand Down
10 changes: 9 additions & 1 deletion deps/undici/src/lib/api/api-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ class StreamHandler extends AsyncResource {
{ callback, body: res, contentType, statusCode, statusMessage, headers }
)
} else {
if (factory === null) {
return
}

res = this.runInAsyncScope(factory, null, {
statusCode,
headers,
Expand Down Expand Up @@ -152,14 +156,18 @@ class StreamHandler extends AsyncResource {
onData (chunk) {
const { res } = this

return res.write(chunk)
return res ? res.write(chunk) : true
}

onComplete (trailers) {
const { res } = this

removeSignal(this)

if (!res) {
return
}

this.trailers = util.parseHeaders(trailers)

res.end()
Expand Down
2 changes: 1 addition & 1 deletion deps/undici/src/lib/api/readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ function consumeEnd (consume) {
pos += buf.byteLength
}

resolve(dst)
resolve(dst.buffer)
} else if (type === 'blob') {
if (!Blob) {
Blob = require('buffer').Blob
Expand Down
25 changes: 19 additions & 6 deletions deps/undici/src/lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

const assert = require('assert')
const net = require('net')
const http = require('http')
const { pipeline } = require('stream')
const util = require('./core/util')
const timers = require('./timers')
Expand Down Expand Up @@ -93,6 +94,7 @@ const {
HTTP2_HEADER_AUTHORITY,
HTTP2_HEADER_METHOD,
HTTP2_HEADER_PATH,
HTTP2_HEADER_SCHEME,
HTTP2_HEADER_CONTENT_LENGTH,
HTTP2_HEADER_EXPECT,
HTTP2_HEADER_STATUS
Expand Down Expand Up @@ -269,7 +271,7 @@ class Client extends DispatcherBase {
this[kConnector] = connect
this[kSocket] = null
this[kPipelining] = pipelining != null ? pipelining : 1
this[kMaxHeadersSize] = maxHeaderSize || 16384
this[kMaxHeadersSize] = maxHeaderSize || http.maxHeaderSize
this[kKeepAliveDefaultTimeout] = keepAliveTimeout == null ? 4e3 : keepAliveTimeout
this[kKeepAliveMaxTimeout] = keepAliveMaxTimeout == null ? 600e3 : keepAliveMaxTimeout
this[kKeepAliveTimeoutThreshold] = keepAliveTimeoutThreshold == null ? 1e3 : keepAliveTimeoutThreshold
Expand Down Expand Up @@ -1068,7 +1070,9 @@ function onParserTimeout (parser) {

function onSocketReadable () {
const { [kParser]: parser } = this
parser.readMore()
if (parser) {
parser.readMore()
}
}

function onSocketError (err) {
Expand Down Expand Up @@ -1689,7 +1693,7 @@ function writeH2 (client, session, request) {
const h2State = client[kHTTP2SessionState]

headers[HTTP2_HEADER_AUTHORITY] = host || client[kHost]
headers[HTTP2_HEADER_PATH] = path
headers[HTTP2_HEADER_METHOD] = method

if (method === 'CONNECT') {
session.ref()
Expand All @@ -1716,10 +1720,14 @@ function writeH2 (client, session, request) {
})

return true
} else {
headers[HTTP2_HEADER_METHOD] = method
}

// https://tools.ietf.org/html/rfc7540#section-8.3
// :path and :scheme headers must be omited when sending CONNECT

headers[HTTP2_HEADER_PATH] = path
headers[HTTP2_HEADER_SCHEME] = 'https'

// https://tools.ietf.org/html/rfc7231#section-4.3.1
// https://tools.ietf.org/html/rfc7231#section-4.3.2
// https://tools.ietf.org/html/rfc7231#section-4.3.5
Expand Down Expand Up @@ -1856,6 +1864,7 @@ function writeH2 (client, session, request) {
stream.cork()
stream.write(body)
stream.uncork()
stream.end()
request.onBodySent(body)
request.onRequestSent()
} else if (util.isBlobLike(body)) {
Expand Down Expand Up @@ -2090,13 +2099,17 @@ async function writeIterable ({ h2stream, body, client, request, socket, content
throw socket[kError]
}

if (!h2stream.write(chunk)) {
const res = h2stream.write(chunk)
request.onBodySent(chunk)
if (!res) {
await waitForDrain()
}
}
} catch (err) {
h2stream.destroy(err)
} finally {
request.onRequestSent()
h2stream.end()
h2stream
.off('close', onDrain)
.off('drain', onDrain)
Expand Down
12 changes: 7 additions & 5 deletions deps/undici/src/lib/compat/dispatcher-weakref.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ class CompatFinalizer {
}

register (dispatcher, key) {
dispatcher.on('disconnect', () => {
if (dispatcher[kConnected] === 0 && dispatcher[kSize] === 0) {
this.finalizer(key)
}
})
if (dispatcher.on) {
dispatcher.on('disconnect', () => {
if (dispatcher[kConnected] === 0 && dispatcher[kSize] === 0) {
this.finalizer(key)
}
})
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion deps/undici/src/lib/core/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ function processHeader (request, key, val, skipAppend = false) {
key.toLowerCase() === 'content-type'
) {
request.contentType = val
request.headers += processHeaderValue(key, val)
if (skipAppend) request.headers[key] = processHeaderValue(key, val, skipAppend)
else request.headers += processHeaderValue(key, val)
} else if (
key.length === 17 &&
key.toLowerCase() === 'transfer-encoding'
Expand Down
4 changes: 3 additions & 1 deletion deps/undici/src/lib/fetch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,7 @@ async function httpNetworkOrCacheFetch (
// user agents should append `User-Agent`/default `User-Agent` value to
// httpRequest’s header list.
if (!httpRequest.headersList.contains('user-agent')) {
httpRequest.headersList.append('user-agent', 'undici')
httpRequest.headersList.append('user-agent', __filename.endsWith('index.js') ? 'undici' : 'node')
}

// 15. If httpRequest’s cache mode is "default" and httpRequest’s header
Expand Down Expand Up @@ -1406,6 +1406,8 @@ async function httpNetworkOrCacheFetch (
}
}

httpRequest.headersList.delete('host')

// 20. If includeCredentials is true, then:
if (includeCredentials) {
// 1. If the user agent is not configured to block cookies for httpRequest
Expand Down
Loading
Loading