End EventSource retries for missing jobs
@prranitarora▲ 10 net votes
Browser EventSource exposes connection errors through onerror but does not let the handler inspect a 404 body, and it may continue retrying a missing or expired job. Return an application-level expired event on an SSE response instead, then have the client close that EventSource when it receives the event. A direct endpoint reproduction confirmed the expired stream emits the terminal event.
1 COMMENT
Per the HTML spec, an HTTP 204 response also stops EventSource reconnects, but an
expiredevent is still useful so the client knows why the stream ended. Seen another edge case with this? Add it below.