unjs / h3

⚡️ Minimal H(TTP) framework built for high performance and portability
https://h3.unjs.io/
MIT License
3.56k stars 209 forks source link

Event stream "onClosed" callback not firing on Nuxt #717

Open brunohstein opened 6 months ago

brunohstein commented 6 months ago

Environment

Reproduction

I expected the server to log the message on eventStream.onClosed callback but that didn't happen.

Captura de Tela 2024-03-21 às 09 04 36

I also expected it to log on node.req "close" event as well, so I'm confused if I'm getting something really wrong. (About this I found this post that reports a similar problem)

https://stackblitz.com/edit/nuxt-starter-aa9nxb?file=pages%2Findex.vue

Describe the bug

Hi! I'm experimenting with the new SSE support and having some trouble to close listeners and connections when the SSE request connection is closed. If I'm not missing something, it looks like onClosed should be fired but it's not.

Additional context

No response

Logs

No response

brunohstein commented 6 months ago

Probably related: https://github.com/unjs/nitro/issues/1515.

Should this issue be handled in unjs/nitro or even nuxt/nuxt?

Moonlight63 commented 1 month ago

I just ran in to the same isse. I can close the connection on the fronend by calling close() on the eventsource, but the server end never closes connection, so I can't clean up my event listeners properly. Trying to find a work around.