Make reconnection failure error non-fatal to allow service failover

A single service failing to reconnect should not kill the entire
pipeline. Non-fatal errors flow through the pipeline so application
code (e.g. ServiceSwitcher) can handle failover to a backup service.
This commit is contained in:
Mark Backman
2026-03-30 12:29:46 -04:00
parent 86a16d53bc
commit f37bf989dd

View File

@@ -107,12 +107,12 @@ class WebsocketService(ABC):
) )
wait_time = exponential_backoff_time(attempt) wait_time = exponential_backoff_time(attempt)
await asyncio.sleep(wait_time) await asyncio.sleep(wait_time)
fatal_msg = f"{self} failed to reconnect after {max_retries} attempts" msg = f"{self} failed to reconnect after {max_retries} attempts"
if last_exception: if last_exception:
fatal_msg += f": {last_exception}" msg += f": {last_exception}"
logger.error(fatal_msg) logger.error(msg)
if report_error: if report_error:
await report_error(ErrorFrame(fatal_msg, fatal=True)) await report_error(ErrorFrame(msg))
return False return False
finally: finally:
self._reconnect_in_progress = False self._reconnect_in_progress = False