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

response.body?.cancel() of fetch causes unexpected behaviors in App Router #72389

Open
akkadaska opened this issue Nov 6, 2024 · 1 comment
Labels
bug Issue was opened via the bug report template.

Comments

@akkadaska
Copy link

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/lucid-cohen-8r5tyq?workspaceId=cf95a29a-9e60-48fa-8cf5-0d217db0d3c6

To Reproduce

  1. Build and start server (npm run build && npm run start)
  2. Access /

Current vs. Expected behavior

Expected:

  • The ReadableStream (response.body) is successfully cancelled.

Current:

  • response.body?.cancel() does not resolve, causing the page to not return.
  • Once response.body?.cancel() is called, the Next.js server does not terminate when Ctrl + C is pressed in the terminal.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP Fri Mar 29 23:14:13 UTC 2024
  Available memory (MB): 39993
  Available CPU cores: 20
Binaries:
  Node: 22.11.0
  npm: 10.9.0
  Yarn: 1.22.15
  pnpm: 9.10.0
Relevant Packages:
  next: 15.0.2 // Latest available version is detected (15.0.2).
  eslint-config-next: 15.0.2
  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 start (local), Other (Deployed)

Additional context

Reproduced with not only Next.js v15.0.2 but also v14.2.17 at least.
I know the way to get only header or consume body in other way. This issue focuses on the bug with response.body.cancel.

@akkadaska akkadaska added the bug Issue was opened via the bug report template. label Nov 6, 2024
@JesseKoldewijn
Copy link
Contributor

Not sure what the surrounding situation is, but perhaps the use of an abortSignal could do the trick? Just a suggestion ofc ;)

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

2 participants