Open vikstrous2 opened 9 months ago
When 503 error occurs, plugin invokes a logic to create a new EventSource by calling ensureEventSourceOnElement
function:
https://github.com/bigskysoftware/htmx/blob/master/dist/ext/sse.js#L243
That function on its own calls ensureEventSource
that instantiates a new EventSource:
https://github.com/bigskysoftware/htmx/blob/master/dist/ext/sse.js#L226
What happens is that new EventSource is completely missing previously added event listeners of a previous EventSource as the logic to add that happens inside the registerSSE
function that is not being called anywhere when the new EventSource is being created:
https://github.com/bigskysoftware/htmx/blob/master/dist/ext/sse.js#L157
I have a basic SSE updated div. Let's say:
I have a server that responds with an event stream like:
When I shut down the server and start it back up fast enough for the browser to reconnect without an error, the dom continues to be updated.
If I shut down the server for long enough for the browser to retry and see a 503 error and then start it back up, it htmx still reconnects to the stream, but it doesn't update any dom elements from that point going forward unless I reload the page.
I hope this is enough information to understand the issue. Let me know if you need a more thorough repro.