-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
@astrojs/node-6.1.0
seems to have broken SSE functionality
#9239
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
Comments
The only change we have in 6.1.0 is #9125 and I'm not sure how that's causing the issue. I think this is expected though. When you reload (presumably) http://localhost:4321/api/stream, you disconnect the stream, which causes the Which means you can no longer |
Seconding bluwy, I think the current behavior is expected. The alternative is that your ReadableStreams continue to produce chunks long after the visitor has disconnected, possibly as long as the server stays online. |
Ok that makes sense, thanks for looking into this! I'm kinda new to SSE so could anyone point me in the right direction on how to implement this correctly? As cancelling the |
@0xk1f0 Looking at @wassfila's example that you are following, the server state (
Not manually, when a visitor comes back they will start receiving events from that point on, same as they would have on first visit. |
That's fair, but I meant survive in terms of "how do i not make it crash" ? :D |
You could unsubscribe the callback from the EventEmitter. I am not familiar with Node's EventEmitter, but if it was an EventTarget, you could create an AbortController for each request, pass its |
Closing as the current behavior is correct. |
For anyone that might come across this, I managed to make it work properly. I published the modified example here. |
I see you are using |
That's a good point! Adjusted my example, I think it should be more appropriate now. |
thanks @0xk1f0 I updated my sample with your cancel fix and mentioned your repo https://github.com/MicroWebStacks/astro-examples#03_sse-counter |
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
I noticed that
@astrojs/node-6.1.0
seems to have broken SSE in my project. I used the reference implementation in this astro-examples Repository. It is a bit out of date but can be used to reproduce by bumping the dependenciesWith this configuration, SSE works when first connecting to the site (running via
npm run preview
). The issue arises when you reload the site, as the counter stops and astro crashes with:What's the expected result?
As noted above with the configuration of
SSE works as expected, even after reloading the site and counts up normally:
Link to Minimal Reproducible Example
https://github.com/0xk1f0/astro-examples/tree/main/03_sse-counter
Participation
The text was updated successfully, but these errors were encountered: