htmx-extensions icon indicating copy to clipboard operation
htmx-extensions copied to clipboard

SSE Retries without Last-Event-ID Header

Open azdle opened this issue 2 months ago • 0 comments

When the browser retries an SSE connection it sets a Last-Event-Id header that contains the event ID of the last event it received. But when the the htmx sse extension retries the connection it doesn't set that header.

For me this ends up duplicating a bunch of messages because, to the server, the re-connection is indistinguishable from a full page reload or a new tab being opened which needs the event history.

As far as I know it's impossible to set any headers on the request generated by constructing a new EventSource. Is there some other way to prevent randomly getting duplicate events without also possibly missing some events?

azdle avatar Nov 02 '25 16:11 azdle