From bb3568574a74069dcc0bd78b53045cdef1d6898c Mon Sep 17 00:00:00 2001 From: Jean Brito Date: Thu, 22 Aug 2024 11:57:45 -0300 Subject: [PATCH] fix: Reload if too much retries --- src/injected.ts | 10 ++++++++++ src/servers/preload/gitCommitHash.ts | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/injected.ts b/src/injected.ts index abe4feeff..e7f06a94d 100644 --- a/src/injected.ts +++ b/src/injected.ts @@ -9,6 +9,8 @@ declare global { console.log('[Rocket.Chat Desktop] Injected.ts'); +let retriesCount = 0; + const resolveWithExponentialBackoff = ( fn: () => Promise, { maxRetries = 5, delay = 1000 } = {} @@ -41,6 +43,14 @@ const start = async () => { console.log('[Rocket.Chat Desktop] window.require is not defined'); console.log('[Rocket.Chat Desktop] Inject start - retrying in 1 seconds'); setTimeout(start, 1000); + if (retriesCount > 10) { + console.log( + '[Rocket.Chat Desktop] Inject start - retries exceeded, forcing reload' + ); + location.reload(); + } else { + retriesCount++; + } return; } diff --git a/src/servers/preload/gitCommitHash.ts b/src/servers/preload/gitCommitHash.ts index b64721142..783d8d3ef 100644 --- a/src/servers/preload/gitCommitHash.ts +++ b/src/servers/preload/gitCommitHash.ts @@ -6,7 +6,6 @@ import { getServerUrl } from './urls'; export const setGitCommitHash = ( gitCommitHash: Server['gitCommitHash'] ): void => { - console.log('setGitCommitHash', gitCommitHash); dispatch({ type: WEBVIEW_GIT_COMMIT_HASH_CHECK, payload: {