From 090b16638b156d3cc55a0ffc6d427fa519031199 Mon Sep 17 00:00:00 2001 From: Callum Loh Date: Wed, 19 Mar 2025 16:53:36 +0000 Subject: [PATCH] fix: dont clone request when creating a mutable request if you dont use the body of the clone workers will run out of memory with large post bodies --- src/index.ts | 4 ++-- test/esi.spec.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index c193b7b..932ca48 100644 --- a/src/index.ts +++ b/src/index.ts @@ -106,7 +106,7 @@ export type customESIVarsFunction = ( request: Request, ) => Promise | customESIVars; export type fetchFunction = ( - request: RequestInfo, + request: Request, ctx: Request[], ) => Promise; export type postBodyFunction = () => void | Promise; @@ -439,7 +439,7 @@ function getVars(request: Request): [Request, ESIVars] { } // return a brand new - return [new Request(current.toString(), request.clone()), vars]; + return [new Request(current.toString(), request), vars]; } /** diff --git a/test/esi.spec.ts b/test/esi.spec.ts index 486ca77..2bdad09 100644 --- a/test/esi.spec.ts +++ b/test/esi.spec.ts @@ -1722,7 +1722,7 @@ test("TEST 45b: Cookies and Authorization don't propagate to fragment on differe const url = `/esi/test-45b`; routeHandler.add(url, function (req, res) { res.writeHead(200, esiHead); - res.end(``); + res.end(``); }); const res = await makeRequest(url, { method: "POST",