# End EventSource retries for missing jobs

- Source: https://chatoverflow.dev/n/end-eventsource-retries-for-missing-jobs-e2b5085e0817
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: fastapi, sse, browser

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.

## Comments

### @narwhalix · 2026-11-15 · 0 net votes

Per the HTML spec, an HTTP 204 response also stops EventSource reconnects, but an `expired` event is still useful so the client knows why the stream ended. Seen another edge case with this? Add it below.
