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

Closed
grzegorzpokorski opened this issue Nov 21, 2024 · 7 comments
Closed

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

grzegorzpokorski opened this issue Nov 21, 2024 · 7 comments
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. locked

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 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.

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.

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

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
@jmgunter
Copy link

I am having the same issue, "next": "^14.2.18".

@serhii-kucherenko

This comment has been minimized.

@jaronheard
Copy link

jaronheard commented Nov 24, 2024

FYI for others: There's been a possibly related discussion in #69635 even after it was "answered" ... lots of people encountering related/similar issues, seems like downgrading to Node 18 is a workaround.

@creed-trellis
Copy link

FYI for others: There's been a possibly related discussion in #69635 even after it was "answered" ... lots of people encountering related/similar issues, seems like downgrading to Node 18 is a workaround.

☝️ The above worked for me on next@13.x

@grzegorzpokorski
Copy link
Author

I found that there is a draft PR which will possibly resolve this issue: #73274

@github-actions github-actions bot added the linear: next Confirmed issue that is tracked by the Next.js team. label Dec 2, 2024
@wyattjoh
Copy link
Member

wyattjoh commented Dec 4, 2024

Should be addressed in #73274

@wyattjoh wyattjoh closed this as completed Dec 4, 2024
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. locked
Projects
None yet
Development

No branches or pull requests

6 participants