From 62fa5a96e2d3f573e6551ecf584a5d2cdd95d309 Mon Sep 17 00:00:00 2001 From: Hunter Miller Date: Thu, 19 Feb 2026 15:17:42 -0600 Subject: [PATCH] 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. --- extensions/tlon/src/urbit/sse-client.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/extensions/tlon/src/urbit/sse-client.ts b/extensions/tlon/src/urbit/sse-client.ts index 8559e18746b..9416223634c 100644 --- a/extensions/tlon/src/urbit/sse-client.ts +++ b/extensions/tlon/src/urbit/sse-client.ts @@ -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;