aiohttp-debugtoolbar
aiohttp-debugtoolbar copied to clipboard
Fix SSE endpoint
Portend sse implementation works like simple polling so easily could be switched to ajax or websokets for message push. Javascript and backend implementation should be fixed.
I want help, but I can not understand how it works. It is looks like it send one request per second to http://127.0.0.1:9000/_debugtoolbar/sse?request_id=313339383833313133303438313638 and get the same data every time.
You are right this SSE work more like regular polling then actual server push. The reason why data is the same because you do not have new request since last poll. Try to refresh page of demo app in separate tab and you will see new data in SSE request.
I think the /sse endpoint simply closes the connection like a regular request, forcing the client to reopen it: https://github.com/aio-libs/aiohttp-debugtoolbar/blob/master/aiohttp_debugtoolbar/views.py#L156
Instead of switching to websockets, we can probably just fix this endpoint by using aiohttp-sse or something: https://github.com/aio-libs/aiohttp-sse#example
This is probably a simple task and shouldn't require making any changes to the client code.