Merge pull request #35095 from overleaf/lg-node-24-17-platform-compat

[Node 24.17.0][Platform packages] Fix node-fetch keep-alive false positive and bump clsi yauzl for Node 24.17

GitOrigin-RevId: 9e0382533d45e1e3b3ed88d4ccfc577591666e10
This commit is contained in:
Andrew Rumble
2026-09-17 11:24:02 +00:00
committed by Copybot
parent f1e3093ae3
commit 152004a600
3 changed files with 26 additions and 5 deletions
+22 -1
View File
@@ -1,5 +1,5 @@
diff --git a/lib/index.js b/lib/index.js
index 567ff5d..8eb45f7 100644
index 567ff5d..a7a38dd 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -545,8 +545,8 @@ function clone(instance) {
@@ -74,3 +74,24 @@ index 567ff5d..8eb45f7 100644
response = new Response(body, response_options);
resolve(response);
return;
@@ -1738,13 +1738,13 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
if (headers['transfer-encoding'] === 'chunked' && !headers['content-length']) {
response.once('close', function (hadError) {
- // tests for socket presence, as in some situations the
- // the 'socket' event is not triggered for the request
- // (happens in deno), avoids `TypeError`
- // if a data listener is still present we didn't end cleanly
- const hasDataListener = socket && socket.listenerCount('data') > 0;
-
- if (hasDataListener && !hadError) {
+ // A kept-alive socket (Node >= 24.16) still has its 'data'
+ // listener attached when the response 'close' event fires, so
+ // the old socket.listenerCount('data') check reported a false
+ // "Premature close". response.complete is true only once the
+ // terminating zero-length chunk has been received, so it tells
+ // a clean end apart from a genuine truncation.
+ if (!response.complete && !hadError) {
const err = new Error('Premature close');
err.code = 'ERR_STREAM_PREMATURE_CLOSE';
errorCallback(err);
+1 -1
View File
@@ -53,6 +53,6 @@
"timekeeper": "2.2.0",
"typescript": "^5.0.4",
"vitest": "4.1.5",
"yauzl": "^2.10.0"
"yauzl": "^3.4.0"
}
}
+3 -3
View File
@@ -6721,7 +6721,7 @@ __metadata:
typescript: "npm:^5.0.4"
vitest: "npm:4.1.5"
workerpool: "npm:^6.1.5"
yauzl: "npm:^2.10.0"
yauzl: "npm:^3.4.0"
languageName: unknown
linkType: soft
@@ -24692,7 +24692,7 @@ __metadata:
"node-fetch@patch:node-fetch@npm%3A2.7.0#~/.yarn/patches/node-fetch-npm-2.7.0.patch":
version: 2.7.0
resolution: "node-fetch@patch:node-fetch@npm%3A2.7.0#~/.yarn/patches/node-fetch-npm-2.7.0.patch::version=2.7.0&hash=932504"
resolution: "node-fetch@patch:node-fetch@npm%3A2.7.0#~/.yarn/patches/node-fetch-npm-2.7.0.patch::version=2.7.0&hash=adffc0"
dependencies:
whatwg-url: "npm:^5.0.0"
peerDependencies:
@@ -24700,7 +24700,7 @@ __metadata:
peerDependenciesMeta:
encoding:
optional: true
checksum: 10c0/b7b79ce343b3b4a0087a4c1c4294ea89536192767025dd786ebd77fd1946f64337605580c9f9434a855ef4ffaaf2adad189ceaa99783ae038acb400e552ee846
checksum: 10c0/287e362e37bb5334ec9047abe3a0e3f0a4ca99dc1c52e29a43336fe086ac7b35a842b83ee6875ba9c822858608d892c392b3c92d7435abf93f14933f40997fa2
languageName: node
linkType: hard