You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Astro v5.1.1
Node v20.9.0
System macOS (arm64)
Package Manager npm
Output server
Adapter @astrojs/node
Integrations none
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
While trying to implement SSE with node adapter in Astro, it seems the abort event is not triggered on request.signal when the connection is closed.
exportconstclients=newSet()asSet<(message: string)=>void>;exportconstGET: APIRoute=({ request })=>{constresponseHeaders={"Content-Type": "text/event-stream","Cache-Control": "no-cache",Connection: "keep-alive",};conststream=newReadableStream({start(controller){constencoder=newTextEncoder();// Function to send messages to this clientconstsend=(message: string)=>{controller.enqueue(encoder.encode(`data: ${message}\n\n`));};// Add the send function to the set of clientsclients.add(send);// Send an initial messagesend("Connected to SSE");request.signal.addEventListener("abort",()=>{console.log("Client disconnected ");clients.delete(send);controller.close();});},});returnnewResponse(stream,{headers: responseHeaders});};
What's the expected result?
The following callback should be called when the client disconnects.
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
While trying to implement SSE with node adapter in Astro, it seems the
abort
event is not triggered onrequest.signal
when the connection is closed.What's the expected result?
The following callback should be called when the client disconnects.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-yi4swteg?file=src%2Fpages%2Fsse.ts
Participation
The text was updated successfully, but these errors were encountered: