Skip to content

Commit 2a3548e

Browse files
mcollinajuanarbol
authored andcommitted
deps: update undici to 6.28.1
PR-URL: #65790 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Filip Skokan <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 839480a commit 2a3548e

9 files changed

Lines changed: 504 additions & 257 deletions

File tree

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ async function connectH1 (client, socket) {
876876

877877
function clearIdleSocketValidation (socket) {
878878
if (socket[kIdleSocketValidationTimeout]) {
879-
clearTimeout(socket[kIdleSocketValidationTimeout])
879+
clearImmediate(socket[kIdleSocketValidationTimeout])
880880
socket[kIdleSocketValidationTimeout] = null
881881
}
882882

@@ -885,15 +885,23 @@ function clearIdleSocketValidation (socket) {
885885

886886
function scheduleIdleSocketValidation (client, socket) {
887887
socket[kIdleSocketValidation] = 1
888-
socket[kIdleSocketValidationTimeout] = setTimeout(() => {
888+
// Yield to the check phase (after poll) so unsolicited bytes / FIN / RST
889+
// already pending on this idle keep-alive socket are processed before the
890+
// next request is written (GHSA-35p6-xmwp-9g52).
891+
//
892+
// setTimeout(0) pays Node's ~1ms timer floor on every sequential reuse
893+
// (#5493). setImmediate avoids that, but an *unref'd* Immediate lets poll
894+
// block for ~500ms when the event loop is otherwise idle (#5600 / #5606).
895+
// A ref'd Immediate both keeps the pending request alive and makes poll
896+
// return immediately — the hybrid those issues asked for.
897+
socket[kIdleSocketValidationTimeout] = setImmediate(() => {
889898
socket[kIdleSocketValidationTimeout] = null
890899
socket[kIdleSocketValidation] = 2
891900

892901
if (client[kSocket] === socket && !socket.destroyed) {
893902
client[kResume]()
894903
}
895-
}, 0)
896-
socket[kIdleSocketValidationTimeout].unref?.()
904+
})
897905
}
898906

899907
/**

deps/undici/src/lib/handler/retry-handler.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class RetryHandler {
9090
this.end = null
9191
this.etag = null
9292
this.resume = null
93+
this.headersSent = false
9394

9495
// Handle possible onConnect duplication
9596
this.handler.onConnect(reason => {
@@ -102,6 +103,20 @@ class RetryHandler {
102103
})
103104
}
104105

106+
checkpointResponseEnd (headers, resume) {
107+
if (this.end == null && this.opts.method !== 'HEAD') {
108+
const contentLength = headers['content-length']
109+
this.end = contentLength != null ? Number(contentLength) - 1 : null
110+
111+
assert(
112+
this.end == null || Number.isFinite(this.end),
113+
'invalid content-length'
114+
)
115+
}
116+
117+
this.resume = this.end != null ? resume : null
118+
}
119+
105120
onRequestSent () {
106121
if (this.handler.onRequestSent) {
107122
this.handler.onRequestSent()
@@ -191,6 +206,8 @@ class RetryHandler {
191206

192207
if (statusCode >= 300) {
193208
if (this.retryOpts.statusCodes.includes(statusCode) === false) {
209+
this.headersSent = true
210+
this.checkpointResponseEnd(headers, resume)
194211
return this.handler.onHeaders(
195212
statusCode,
196213
rawHeaders,
@@ -259,8 +276,15 @@ class RetryHandler {
259276

260277
const { start, size, end = size - 1 } = contentRange
261278

262-
assert(this.start === start, 'content-range mismatch')
263-
assert(this.end == null || this.end === end, 'content-range mismatch')
279+
if (this.start !== start || (this.end != null && this.end !== end)) {
280+
this.abort(
281+
new RequestRetryError('Content-Range mismatch', statusCode, {
282+
headers,
283+
data: { count: this.retryCount }
284+
})
285+
)
286+
return false
287+
}
264288

265289
this.resume = resume
266290
return true
@@ -272,6 +296,7 @@ class RetryHandler {
272296
const range = parseRangeHeader(headers['content-range'])
273297

274298
if (range == null) {
299+
this.headersSent = true
275300
return this.handler.onHeaders(
276301
statusCode,
277302
rawHeaders,
@@ -310,6 +335,7 @@ class RetryHandler {
310335
)
311336

312337
this.resume = resume
338+
this.headersSent = true
313339
this.etag = headers.etag != null ? headers.etag : null
314340

315341
// Weak etags are not useful for comparison nor cache
@@ -349,7 +375,7 @@ class RetryHandler {
349375
}
350376

351377
onError (err) {
352-
if (this.aborted || isDisturbed(this.opts.body)) {
378+
if (this.aborted || isDisturbed(this.opts.body) || (this.headersSent && this.resume == null)) {
353379
return this.handler.onError(err)
354380
}
355381

deps/undici/src/lib/llhttp/wasm_build_env.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11

2-
> [email protected].0 prebuild:wasm
2+
> [email protected].1 prebuild:wasm
33
> node build/wasm.js --prebuild
44

55
> docker build --platform=linux/x86_64 -t llhttp_wasm_builder -f /home/runner/work/node/node/deps/undici/src/build/Dockerfile /home/runner/work/node/node/deps/undici/src
66

77

88

9-
> [email protected].0 build:wasm
9+
> [email protected].1 build:wasm
1010
> node build/wasm.js --docker
1111

1212
> docker run --rm -t --platform=linux/x86_64 --user 1001:1001 --mount type=bind,source=/home/runner/work/node/node/deps/undici/src/lib/llhttp,target=/home/node/undici/lib/llhttp llhttp_wasm_builder node build/wasm.js

0 commit comments

Comments
 (0)