From eb54e85a0a6f0a0c2b4547e9967901d7ffd6060f Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Thu, 18 Jan 2024 15:15:42 +0100 Subject: [PATCH] Revert "Fix: respect init.cache if fetch input is request instance" This reverts commit c5239087ffc9dba9402759cf5e687297b01b943c. --- packages/next/src/server/lib/patch-fetch.ts | 3 +-- test/e2e/app-dir/logging/app/fetch-no-store/page.js | 12 ------------ test/e2e/app-dir/logging/fetch-logging.test.ts | 10 ---------- 3 files changed, 1 insertion(+), 24 deletions(-) delete mode 100644 test/e2e/app-dir/logging/app/fetch-no-store/page.js diff --git a/packages/next/src/server/lib/patch-fetch.ts b/packages/next/src/server/lib/patch-fetch.ts index 4835f81956315..3ee5873f75e8b 100644 --- a/packages/next/src/server/lib/patch-fetch.ts +++ b/packages/next/src/server/lib/patch-fetch.ts @@ -236,8 +236,7 @@ export function patchFetch({ typeof (input as Request).method === 'string' const getRequestMeta = (field: string) => { - // If request input is present but init is not, retrieve from input first. - const value = isRequestInput && !init ? (input as any)[field] : null + let value = isRequestInput ? (input as any)[field] : null return value || (init as any)?.[field] } diff --git a/test/e2e/app-dir/logging/app/fetch-no-store/page.js b/test/e2e/app-dir/logging/app/fetch-no-store/page.js deleted file mode 100644 index df09454b4c975..0000000000000 --- a/test/e2e/app-dir/logging/app/fetch-no-store/page.js +++ /dev/null @@ -1,12 +0,0 @@ -export default async function Page() { - await fetch( - new Request( - 'https://next-data-api-endpoint.vercel.app/api/random?request-input' - ), - { - cache: 'no-store', - } - ) - - return
Hello World!
-} diff --git a/test/e2e/app-dir/logging/fetch-logging.test.ts b/test/e2e/app-dir/logging/fetch-logging.test.ts index da012ef5d3cb3..d5c0ef341359d 100644 --- a/test/e2e/app-dir/logging/fetch-logging.test.ts +++ b/test/e2e/app-dir/logging/fetch-logging.test.ts @@ -141,16 +141,6 @@ createNextDescribe( expect(output).toContain('Cache missed reason: (noStore call)') }) }) - - it('should respect request.init.cache when use with fetch input is instance', async () => { - const logLength = next.cliOutput.length - await next.fetch('/fetch-no-store') - - await retry(() => { - const output = stripAnsi(next.cliOutput.slice(logLength)) - expect(output).toContain('Cache missed reason: (cache: no-store)') - }) - }) } } else { // No fetches logging enabled