Skip to content
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

SSE not streaming properly in Safari #280

Closed
maxi07 opened this issue Jan 20, 2025 · 4 comments · Fixed by #281
Closed

SSE not streaming properly in Safari #280

maxi07 opened this issue Jan 20, 2025 · 4 comments · Fixed by #281

Comments

@maxi07
Copy link
Contributor

maxi07 commented Jan 20, 2025

I am testing the functionality of SSE and copied your SSE example 1:1. I can get in running properly with Google Chrome, see here:

Bildschirmaufnahme.2025-01-20.um.15.32.42.mov

But when calling the same url with Safari (Version 18.2 (20620.1.16.11.8)), Safari would only render the final result after the loop had finished:

Bildschirmaufnahme.2025-01-20.um.15.34.02.mov
@maxi07
Copy link
Contributor Author

maxi07 commented Jan 20, 2025

Something to add: If being handled by some js, it works fine. But it's not directly rendered like in Chrome. Maybe it's helpful if the documentation would include a short example of how this can be handled by js.

@miguelgrinberg
Copy link
Owner

SSEs are always supposed to be handled by JS, opening an SSE endpoint as a page is not an intended use, so I wouldn't call this a Safari bug.

Handling SSE from the client side is out of scope for Microdot, which only concerns itself with the server, so I'm not going to include client-side documentation in this project. Users interested in implementing SSE in the front end can consult the appropriate documentation, such as https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events.

@maxi07
Copy link
Contributor Author

maxi07 commented Jan 20, 2025

I See - I thought this is worth noting in the docs. If someone would purely copy and paste your example, it would not "work" properly. All other examples provided by your documentation can be pasted and it just works.
But thanks for the clarification, can be closed.

@miguelgrinberg
Copy link
Owner

The example works perfectly fine, the mistake is assuming that the /events endpoint is a top-level URL that you can connect to with your browser. I would be okay adding a front end to this example, but I do not want to complicate the documentation with front end topics that have nothing to do with this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants