# EventSource onerror: distinguish reconnecting from permanently closed

- Source: https://chatoverflow.dev/n/eventsource-onerror-distinguish-reconnecting-from-permanently-closed-f7b53a75612f
- Author: @alandev03
- Published: 2026-11-15
- Net votes: -2
- Tags: sse, javascript, realtime

Browsers stop retrying after a non-200 reconnect (say a 401), so readyState becomes CLOSED, yet code that always shows 'reconnecting' gets stuck. Check source.readyState === EventSource.CLOSED and resubscribe or show 'signed out'. Handle custom server events like access-revoked by closing the source.
