Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Response.clone: Body has already been consumed. #73035

Open
grzegorzpokorski opened this issue Nov 21, 2024 · 0 comments
Open

TypeError: Response.clone: Body has already been consumed. #73035

grzegorzpokorski opened this issue Nov 21, 2024 · 0 comments
Labels
bug Issue was opened via the bug report template.

Comments

@grzegorzpokorski
Copy link

grzegorzpokorski commented Nov 21, 2024

Link to the code that reproduces this issue

https://github.com/grzegorzpokorski/next-type-error-response-clone

To Reproduce

It is challenging to create minimal reproducible code because this error appears randomly, even within my application. I have attempted to recreate the structure of the application code where I encounter the error. However, in the provided code that aims to reproduce the problem, I cannot replicate the issue – the error simply does not occur. Unfortunately, I cannot share the original application where the error happens.

When the error appears when I navigate to page like this: /post/[id], refresh page in browser in most cases fix error.

What is important is that the error only occurs on SSG pages, such as /post/[id]. My project uses the latest stable version of Next.js (v15.0.3). The application exhibits this behavior both when built locally on my computer and when deployed on Vercel.

Current vs. Expected behavior

Currently I randomly receive a TypeError: Response.clone: Body has already been consumed. error in console. I expect app to work without breaking.

Provide environment information

Node.js v22.11.0

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP Tue Nov 5 00:21:55 UTC 2024
  Available memory (MB): 7843
  Available CPU cores: 8
Binaries:
  Node: 22.11.0
  npm: 10.9.0
  Yarn: N/A
  pnpm: 9.4.0
Relevant Packages:
  next: 15.0.3 // Latest available version is detected (15.0.3).
  eslint-config-next: 15.0.3
  react: 19.0.0-rc-02c0e824-20241028
  react-dom: 19.0.0-rc-02c0e824-20241028
  typescript: 5.6.3
Next.js Config:
  output: N/A

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

Not sure

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

next build (local), Vercel (Deployed)

Additional context

In console I receive error like this:

 ⨯ TypeError: Response.clone: Body has already been consumed.
    at <unknown> (/home/name/project/.next/server/chunks/1241.js:2:6811) {
  digest: '217859647'
}

I spend some time to find what code causes that error in my case and I found that /home/username/project/.next/server/chunks/1241.js:2:6811 points to this code:

return match.then((response: Response) => response.clone())

@grzegorzpokorski grzegorzpokorski added the bug Issue was opened via the bug report template. label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

1 participant