-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
ReadableStream in response body not canceled when client closes connection #9068
Copy link
Copy link
Closed
Labels
- P3: minor bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)pkg: nodeRelated to Node adapter (scope)Related to Node adapter (scope)
Description
Astro Info
Astro v3.5.2
Node v20.2.0
System macOS (x64)
Package Manager pnpm
Output server
Adapter @astrojs/node
Integrations @astrojs/tailwind
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When implementing server-sent events, cancel() is not called when client closes the connection (e.g. closes the tab).
export async function GET() {
const stream = new ReadableStream({
start(controller) {
// do stuff
},
cancel() {
console.log("cancelled");
},
});
return new Response(stream, {
headers: {
"X-Content-Type-Options": "nosniff",
"Content-Type": "text/event-stream; charset=utf-8",
"Transfer-Encoding": "chunked",
},
});
}What's the expected result?
cancelled is logged to the console
Link to Minimal Reproducible Example
https://github.com/pilcrowOnPaper/astro-readable-stream-bug
Participation
- I am willing to submit a pull request for this issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
- P3: minor bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)pkg: nodeRelated to Node adapter (scope)Related to Node adapter (scope)