How to properly terminate H3 EventHandler when using Server-Sent Events? #49
Unanswered
vicentematus
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm working with Server-Sent Events (SSE) in H3 to implement progressive data loading from my database. I've encountered an issue where the server continues processing database operations even after the client disconnects and the
onClosed
callback is triggered.When a client disconnects from the SSE connection, the
onClosed
callback triggers as expected. However, the issue is that the EventHandler continues executing. This means that even though we've closed the client connection, our server is still processing data.See my following code:
What's the recommended approach to terminate the entire EventHandler execution when a client disconnects? Or I'm approaching server-side events the correct way?
Im using
node v20.15.1
[email protected]
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions