| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
| host: str = "0.0.0.0" | ||
| port: int = 8000 | ||
| sse_path: str = "/sse" | ||
| sse_path: str = "/sse/" |
There was a problem hiding this comment.
Why the trailing /?
Sorry, something went wrong.
There was a problem hiding this comment.
Apparently Mount makes it trailing by default.
Starlette adds a trailing slash to the mount path by default and redirects requests without a trailing slash to the path with a trailing slash.
Our test client doesn't follow redirects so didn't like it.
Sorry, something went wrong.
There was a problem hiding this comment.
Discussed offline; we don't want to break current users so switched back to Route but return an empty Response to get around this.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Motivation and Context
The EventSourceResponse from https://github.com/sysid/sse-starlette returns on SSE session disconnect. However, since we start this in a sub task group, the current implementation does nothing when a disconnect happens. This causes the session Route to stay open forever in these cases.
This PR modifies this behavior to close the streams in the SSE server when EventSourceResponse wraps up, and updates ServerSession to properly wrap up and clean up its streams as well when the upstream streams close.
This exposes a different error in that we have this set up as a Route in most cases which shouldn't return None. By fixing the 'running forever' issue we end up seeing exceptions related to this whenever a client disconnects. I updated mount_sse to return an empty response to fix this.
How Has This Been Tested?
Tested manually and ensured that the route was closed when clients close the connection.
Breaking Changes
It isn't breaking, but users need to change the handle_sse function to a Mount to not get "TypeError: 'NoneType' object is not callable" errors when client disconnects.
Types of changes
Checklist
Additional context