8000 Aborting a fetch call to an app router API endpoint does not abort the request when streaming under Vercel's Node Runtime · Issue #77786 · vercel/next.js · GitHub
[go: up one dir, main page]

Skip to content

Aborting a fetch call to an app router API endpoint does not abort the request when streaming under Vercel's Node Runtime #77786

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

Closed
acrognale opened this issue Apr 3, 2025 · 1 comment
Labels
Connection Related to the connection() function. linear: next Confirmed issue that is tracked by the Next.js team.

Comments

@acrognale
Copy link
acrognale commented Apr 3, 2025

Link to the code that reproduces this issue

https://github.com/acrognale/vercel-next-abort-repro

To Reproduce

I've included a standard Next app in the repository that you can start with npm run dev.

Current vs. Expected behavior

When running locally, the request properly aborts. Here is the expected server output:


   ▲ Next.js 15.2.4 (Turbopack)
   - Local:        http://localhost:3000
   - Network:      http://192.168.128.250:3000

 ✓ Starting...
 ✓ Ready in 533ms
 ○ Compiling / ...
 ✓ Compiled / in 744ms
 GET / 200 in 860ms
 ✓ Compiled /favicon.ico in 145ms
 GET /favicon.ico?favicon.45db1c09.ico 200 in 169ms
 ✓ Compiled /api/stream in 125ms
count: 1
count: 2
 GET /api/stream 200 in 2738ms
abort

and on the frontend:

Message 1 at 2025-04-03T16:52:59.275Z
Message 2 at 2025-04-03T16:53:00.276Z
Stream was cancelled!

But when running on Vercel under the Node Runtime, we receive the following:

server:

count: 1
count: 2
count: 3
count: 4
count: 5
count: 6
count: 7
count: 8
count: 9

(and then the function times out because the max duration is 10s.

On the frontend:

Message 1 at 2025-04-03T16:55:04.790Z
Message 2 at 2025-04-03T16:55:05.790Z
Stream was cancelled!

So while the browser is canceling the request, the function on the Node Runtime continues to stream.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.1.0: Thu Oct 10 21:06:57 PDT 2024; root:xnu-11215.41.3~3/RELEASE_ARM64_T6041
  Available memory (MB): 36864
  Available CPU cores: 14
Binaries:
  Node: 22.14.0
  npm: 10.9.2
  Yarn: 1.22.22
  pnpm: 10.6.5
Relevant Packages:
  next: 15.2.4 // Latest available version is detected (15.2.4).
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.8.2
Next.js Config:
  output: N/A

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

Connection

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

Vercel (Deployed)

Additional context

No response

NEXT-4352

@github-actions github-actions bot added the Connection Related to the connection() function. label Apr 3, 2025
@github-actions github-actions bot added the linear: next Confirmed issue that is tracked by the Next.js team. label May 26, 2025
@ztanner
Copy link
Member

Hi there!

Vercel didn't support request cancellation in functions when this issue was created. Support was added recently (here's the article about it).

If you are still unable to get it to work, I suggest opening a Vercel support ticket, as if it works with next start it's most likely not a framework issue.

@ztanner ztanner closed this as completed May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Connection Related to the connection() function. linear: next Confirmed issue that is tracked by the Next.js team.
Projects
None yet
Development

No branches or pull requests

2 participants
0