Closed wwitzel3 closed 1 year ago
I was working on making a reproducer repo and was unable to reproduce using python -m http.server
. This got me digging in to things a bit more and it turns out the Vite proxy was holding the connection open. I wasn't able to get the Vite configuration to work correctly, so I added an .env.local
for CORS origins so I could bypass the Vite proxy completely.
@wwitzel3 , glad you could sort it out. Kind regards.
Hi, I think I am misunderstanding something or doing something wrong, but I am completely stuck on using this package due to event generators never stopping when the connection originates from an
EventSource
creation in the browser. I've tried my best to capture what I'm experiencing below. I really appreciate any help or guidance.I have a very simple test setup using basic JavaScript creating an
EventSource
and a setTimeout that closes it 5 seconds later. I have a simple event generator that is sending a message every second.When I test this with cURL, everything works as expected.
When I use the browser, the generator continues to run even after calling
close()
and closing the browser completely.Here is the stream handler in Python
Here is the JavaScript
Using cURL I can call this endpoint and when I Ctrl-C, I see the disconnect as expected.
Using a very simple JavaScript client in Chrome, after calling
close
OR closing the browser completely, the generator task stays active.After Ctrl-C on the uvicorn server, you can see all the tasks shutting down.