next.js icon indicating copy to clipboard operation
next.js copied to clipboard

[15.0.0-canary.111+] Infinite loading page when fetch has "force-cache" in generateMetadata layout.tsx

Open aXenDeveloper opened this issue 1 year ago • 3 comments

Link to the code that reproduces this issue

https://github.com/aXenDeveloper/next-app-canary

To Reproduce

  1. Clone repo,
  2. pnpm i,
  3. Start app with pnpm dev

or

  1. pnpm create next-app@canary
  2. In src/app/layout.tsx replace metadata to:
    export const generateMetadata = async (): Promise<Metadata> => {
      await fetch("http://localhost:8080/graphql", {
        cache: "force-cache"
      });
    
      return {
        title: "Create Next App",
        description: "Generated by create next app"
      };
    };
    

Current vs. Expected behavior

Loaded home page.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.0.0: Tue Sep 24 23:37:36 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T6020
  Available memory (MB): 16384
  Available CPU cores: 12
Binaries:
  Node: 20.11.0
  npm: 10.2.4
  Yarn: N/A
  pnpm: 9.10.0
Relevant Packages:
  next: 15.0.1-canary.2 // Latest available version is detected (15.0.1-canary.2).
  eslint-config-next: N/A
  react: 19.0.0-rc-45804af1-20241021
  react-dom: 19.0.0-rc-45804af1-20241021
  typescript: 5.6.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Metadata

Which stage(s) are affected? (Select all that apply)

next dev (local), next start (local)

Additional context

When fetch has "force-cache" inside generateMetadata() and API has fetch error then page will have infinite loading.

export const generateMetadata = async (): Promise<Metadata> => {
  await fetch("http://localhost:8080/graphql", {
    cache: "force-cache"
  });

  return {
    title: "Create Next App",
    description: "Generated by create next app"
  };
};

It happens from 15.0.0-canary.111+. 15.0.0-canary.110 works fine.

aXenDeveloper avatar Aug 26 '24 14:08 aXenDeveloper

hello, are you still able to reproduce this in v15.0.0-canary.132?

AbhiShake1 avatar Aug 28 '24 03:08 AbhiShake1

@AbhiShake1 Yes, also happen on canary.132.

aXenDeveloper avatar Aug 28 '24 06:08 aXenDeveloper

Anyone? It starts from here: https://github.com/vercel/next.js/releases/tag/v15.0.0-canary.111 I think the issue starts from here: https://github.com/vercel/next.js/pull/68447 Can you please take a look @huozhi or @eps1lon ?

aXenDeveloper avatar Oct 22 '24 20:10 aXenDeveloper