Dev server doesn't receive SSE close event #12157
Labels
bug: upstream
Bug in a dependency of Vite
p2-edge-case
Bug, but has workaround or limited in scope (priority)
Describe the bug
I am using server-sent events (SSE) and encountered an issue when running Vite dev server.
When a React client is connected to an express.js HTTP SSE endpoint via proxy config, the client should issue a close event that the server receives via
res.on('close'...)
but the event never fires. When I use vite to create a production build, the server event does get fired.I have tried doing a low level implementation SSE implementation and also used a higher level library, better-sse. It was reproducible in both cases.
Reproduction
https://github.com/abcd-ca/vite-sse-issue-example
Steps to reproduce
Steps to Reproduce
Dev mode
Demonstrates SSE not closing connections when the browser window is closed or refreshed. You will see in the Chrome DevTools console that client connections are accumulating when you refresh the page which shouldn't happen.
npm run dev
Prod mode
Demonstrates SSE disconnect working as expected
npm run build
npm start
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: