Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥
TypeScript aiai-agentsai-crawlerai-scrapingai-searchcrawlerdata-extractionhtml-to-markdownllmmarkdownscraperscrapingweb-crawlerweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
feat: patch node-fetch, gcs bug (#3825)
Thomas Kosmas53c2473aa18c
diff --git a/apps/api/package.json b/apps/api/package.jsonindex 6da77245b..14546d739 100644--- a/apps/api/package.json+++ b/apps/api/package.json@@ -216,6 +216,9 @@"shell-quote@<1.8.4": "1.8.4","esbuild@>=0.17.0 <0.28.1": "0.28.1","@opentelemetry/core@>=2.0.0 <2.8.0": "2.8.0"+ },+ "patchedDependencies": {+ "[email protected]": "patches/[email protected]"}},"lint-staged": {diff --git a/apps/api/patches/[email protected] b/apps/api/patches/[email protected]new file mode 100644index 000000000..883c858d5--- /dev/null+++ b/apps/api/patches/[email protected]@@ -0,0 +1,31 @@+diff --git a/lib/index.js b/lib/index.js+index 567ff5da58e83683bec0ea9e86221041ddf9435f..7ca5fc0c441fe25201ce1757d255c945724e7364 100644+--- a/lib/index.js++++ b/lib/index.js+@@ -1738,13 +1738,19 @@ 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) {++ // PATCH (firecrawl): use Node's HTTP-parser-backed completion flag++ // instead of the socket data-listener heuristic. The listener count is++ // teardown-order dependent and false-positives on COMPLETE chunked++ // responses on Node >=22.23.0, breaking gtoken/gaxios OAuth token++ // fetches to googleapis.com/oauth2/v4/token. Genuine truncation still++ // leaves response.complete === false, so real errors still surface.++ // Refs:++ // node-fetch bug: https://github.com/node-fetch/node-fetch/issues/1767++ // related variant: https://github.com/node-fetch/node-fetch/issues/1576++ // upstream PR (diff bug): https://github.com/node-fetch/node-fetch/pull/1687++ // Node trigger: https://nodejs.org/en/blog/release/v22.23.0 (CVE-2026-48931; llhttp 9.4.2)++ // completion flag: https://nodejs.org/api/http.html#messagecomplete++ if (response.complete === false && !hadError) {+ const err = new Error('Premature close');+ err.code = 'ERR_STREAM_PREMATURE_CLOSE';+ errorCallback(err);diff --git a/apps/api/pnpm-lock.yaml b/apps/api/pnpm-lock.yamlindex c8175eabb..305f3412b 100644--- a/apps/api/pnpm-lock.yaml+++ b/apps/api/pnpm-lock.yaml@@ -40,6 +40,11 @@ overrides:esbuild@>=0.17.0 <0.28.1: 0.28.1'@opentelemetry/core@>=2.0.0 <2.8.0': 2.8.0+patchedDependencies:+ hash: cf2058381802eaf328e1cb26b185762ba41e2157a5545e7ed9bba56b7de0c49b+ path: patches/[email protected]+importers:.:@@ -6471,7 +6476,7 @@ snapshots:'@sentry/[email protected]([email protected])':dependencies:https-proxy-agent: 5.0.1- node-fetch: 2.7.0([email protected])+ node-fetch: 2.7.0(patch_hash=cf2058381802eaf328e1cb26b185762ba41e2157a5545e7ed9bba56b7de0c49b)([email protected])progress: 2.0.3proxy-from-env: 1.1.0which: 2.0.2@@ -7027,7 +7032,7 @@ snapshots:buffer: 6.0.3fast-stable-stringify: 1.0.0jayson: 4.2.0([email protected])([email protected])- node-fetch: 2.7.0([email protected])+ node-fetch: 2.7.0(patch_hash=cf2058381802eaf328e1cb26b185762ba41e2157a5545e7ed9bba56b7de0c49b)([email protected])rpc-websockets: 9.1.3superstruct: 2.0.2transitivePeerDependencies:@@ -8170,7 +8175,7 @@ snapshots:extend: 3.0.2https-proxy-agent: 7.0.6is-stream: 2.0.1- node-fetch: 2.7.0([email protected])+ node-fetch: 2.7.0(patch_hash=cf2058381802eaf328e1cb26b185762ba41e2157a5545e7ed9bba56b7de0c49b)([email protected])uuid: 11.1.1transitivePeerDependencies:- encoding@@ -8861,7 +8866,7 @@ snapshots:+ [email protected](patch_hash=cf2058381802eaf328e1cb26b185762ba41e2157a5545e7ed9bba56b7de0c49b)([email protected]):dependencies:whatwg-url: 5.0.0optionalDependencies:@@ -9572,7 +9577,7 @@ snapshots:dependencies:http-proxy-agent: 5.0.0https-proxy-agent: 5.0.1- node-fetch: 2.7.0([email protected])+ node-fetch: 2.7.0(patch_hash=cf2058381802eaf328e1cb26b185762ba41e2157a5545e7ed9bba56b7de0c49b)([email protected])stream-events: 1.0.5uuid: 11.1.1transitivePeerDependencies: