Skip to content

Commit

Permalink
fix: Reload if too much retries
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanfbrito committed Aug 22, 2024
1 parent 8f7567f commit bb35685
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/injected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ declare global {

console.log('[Rocket.Chat Desktop] Injected.ts');

let retriesCount = 0;

const resolveWithExponentialBackoff = <T>(
fn: () => Promise<T>,
{ maxRetries = 5, delay = 1000 } = {}
Expand Down Expand Up @@ -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;
}

Expand Down
1 change: 0 additions & 1 deletion src/servers/preload/gitCommitHash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit bb35685

Please sign in to comment.