Closed
Description
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #22 SMP Tue Jan 10 18:39:00 UTC 2023
Binaries:
Node: 18.14.2
npm: 9.5.0
Yarn: 1.22.19
pnpm: N/A
Relevant Packages:
next: 13.4.10-canary.8
eslint-config-next: 13.4.8
react: 18.2.0
react-dom: 18.2.0
typescript: 5.0.4
Next.js Config:
output: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)
Middleware / Edge (API routes, runtime)
Link to the code that reproduces this issue or a replay of the bug
https://codesandbox.io/p/sandbox/blissful-driscoll-y78mrd
To Reproduce
- open the link from above
- click on "Trigger API call" button
- click on "Cancel API call" button and note in browser network tab that the request which was previously pending is now cancelled
- note how
req.on("close"
event handler didn't run and API route work is still being done
Describe the Bug
Request close event is not firing in the API route when the caller cancels the request
Expected Behavior
Request close event should be fired so that any necessary cleanup can be done
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response