fix(app): keep the updater polling after async native results (#3179)

This commit is contained in:
Hampus authored and GitHub committed 2026-10-03 19:42:41 +02:00
1 parent bc5dcdfe21
commit 583c791016
2 files changed
+13 -13

No files matched your search

+13 -6
View File
@@ -55,6 +55,7 @@ const CHECK_INTERVAL_MS = 5 * 60 * 1000;
const MIN_CHECK_INTERVAL_MS = 60 * 1000;
const MANUAL_DOWNLOAD_REFRESH_TIMEOUT_MS = 5 * 1000;
const WEB_CHECK_TIMEOUT_MS = 15 * 1000;
const NATIVE_CHECK_TIMEOUT_MS = 30 * 1000;
const VERSION_ENDPOINT = '/version.json';
const CURRENT_BUILD_VERSION = Config.PUBLIC_BUILD_VERSION ?? null;
const ALLOWED_WEB_UPDATE_HOSTS = new Set([
@@ -157,6 +158,7 @@ class Updater {
private unsubscribeNativeEvents: (() => void) | null = null;
private updateReadyNagbarDismissedVersion: string | null = null;
private pendingManualDownloadRefreshes = 0;
private checkInProgress = false;
constructor() {
makeAutoObservable(this, {}, {autoBind: true});
@@ -195,10 +197,6 @@ class Updater {
return this.snapshot.context.nativeManualDownloadOptions;
}
private get checkInProgress(): boolean {
return this.snapshot.context.checkInProgress;
}
private get nativeCheckFailed(): boolean {
return this.snapshot.context.nativeCheckFailed;
}
@@ -495,6 +493,7 @@ class Updater {
return;
}
this.checkInProgress = true;
this.transition({type: 'check.started'});
const checkContext: 'user' | 'background' = userInitiated ? 'user' : 'background';
@@ -518,6 +517,7 @@ class Updater {
pushUpdateCheckFailedModal();
}
} finally {
this.checkInProgress = false;
this.transition({type: failed ? 'check.failed' : 'check.finished', now: Date.now()});
}
}
@@ -525,12 +525,17 @@ class Updater {
private async checkNativeUpdate(context: 'user' | 'background'): Promise<boolean> {
const electronApi = getElectronAPI();
if (!electronApi) return false;
let timeoutId: number | undefined;
const timedOut = new Promise<false>((resolve) => {
timeoutId = window.setTimeout(() => resolve(false), NATIVE_CHECK_TIMEOUT_MS);
});
try {
await electronApi.updaterCheck(context);
return true;
return await Promise.race([electronApi.updaterCheck(context).then(() => true), timedOut]);
} catch (error) {
logger.debug('Native update check failed silently:', error);
return false;
} finally {
window.clearTimeout(timeoutId);
}
}
@@ -692,6 +697,7 @@ class Updater {
if (this.checkInProgress) {
return option;
}
this.checkInProgress = true;
this.transition({type: 'check.started'});
let timeoutId: number | undefined;
const timedOut = new Promise<boolean>((resolve) => {
@@ -706,6 +712,7 @@ class Updater {
return this.nativeManualDownloadOptions.find((candidate) => candidate.format === option.format) ?? option;
} finally {
window.clearTimeout(timeoutId);
this.checkInProgress = false;
this.transition({type: 'check.finished', now: Date.now()});
}
}