fix(tlon): add infinite reconnect with reset after max attempts

Instead of giving up after maxReconnectAttempts, wait 10 seconds then
reset the counter and keep trying. This ensures the monitor never
permanently disconnects due to temporary network issues.
This commit is contained in:
Hunter Miller
2026-02-19 15:17:42 -06:00
committed by Josh Lehman
parent 94501d3310
commit 62fa5a96e2

View File

@@ -391,11 +391,16 @@ export class UrbitSSEClient {
return;
}
// If we've hit max attempts, wait longer then reset and keep trying
if (this.reconnectAttempts >= this.maxReconnectAttempts) {
this.logger.error?.(
`[SSE] Max reconnection attempts (${this.maxReconnectAttempts}) reached. Giving up.`,
this.logger.log?.(
`[SSE] Max reconnection attempts (${this.maxReconnectAttempts}) reached. Waiting 10s before resetting...`,
);
return;
// Wait 10 seconds before resetting and trying again
const extendedBackoff = 10000; // 10 seconds
await new Promise((resolve) => setTimeout(resolve, extendedBackoff));
this.reconnectAttempts = 0; // Reset counter to continue trying
this.logger.log?.("[SSE] Reconnection attempts reset, resuming reconnection...");
}
this.reconnectAttempts += 1;