diff --git a/packages/fetch/src/node-fetch-patch.js b/packages/fetch/src/node-fetch-patch.js index 94d25c8cb..10bb96531 100644 --- a/packages/fetch/src/node-fetch-patch.js +++ b/packages/fetch/src/node-fetch-patch.js @@ -1,3 +1,10 @@ +/* +This is a patched version of index.js from node-fetch 3.3.2 (see packages/fetch/node_modules/node-fetch/src/index.js) +This is to fix "Premature close" errors caused by chunked encoding assumptions - see https://github.com/continuedev/continue/issues/5502 +The patch adjusts boundary chunk detection logic (see "PATCH" comment next to patch) +And is based on https://github.com/node-fetch/node-fetch/issues/1576 +*/ + /** * Index.js * @@ -481,9 +488,8 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) { // previousChunk = buf; // }; - // VENDOR note - THIS IS THE REASON I AM PATCHING THIS PACKAGE + // PATCH - THIS IS WHERE THE PATCH IS - FIXES BOUNDARY CHUNKING ISSUE // See https://github.com/node-fetch/node-fetch/issues/1576 - // FIXES BOUNDARY CHUNKING ISSUE const onData = (buf) => { properLastChunkReceived = Buffer.compare(buf.slice(-5), LAST_CHUNK) === 0; diff --git a/packages/fetch/src/patch-test.test.js b/packages/fetch/src/node-fetch-patch.test.js similarity index 95% rename from packages/fetch/src/patch-test.test.js rename to packages/fetch/src/node-fetch-patch.test.js index ee92e8dea..21f930ecb 100644 --- a/packages/fetch/src/patch-test.test.js +++ b/packages/fetch/src/node-fetch-patch.test.js @@ -1,6 +1,7 @@ import { Buffer } from "node:buffer"; import { describe, expect, it } from "vitest"; +// Tests the boundary chunking patch to node fetch made in node-fetch-patch.js (see that file for details). describe("Chunked Transfer Encoding Patch Logic", () => { // The LAST_CHUNK marker "0\r\n\r\n" const LAST_CHUNK = Buffer.from("0\r\n\r\n");