1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Make sure all rejections of orphan promise is catched

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2022-06-15 09:16:59 +03:00
parent b7e165cdba
commit 84fc925d87
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A

View File

@ -5,21 +5,22 @@
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { getStartableStoppable } from "../../../common/utils/get-startable-stoppable"; import { getStartableStoppable } from "../../../common/utils/get-startable-stoppable";
import processCheckingForUpdatesInjectable from "../check-for-updates/process-checking-for-updates.injectable"; import processCheckingForUpdatesInjectable from "../check-for-updates/process-checking-for-updates.injectable";
import withOrphanPromiseInjectable from "../../../common/utils/with-orphan-promise/with-orphan-promise.injectable";
const periodicalCheckForUpdatesInjectable = getInjectable({ const periodicalCheckForUpdatesInjectable = getInjectable({
id: "periodical-check-for-updates", id: "periodical-check-for-updates",
instantiate: (di) => { instantiate: (di) => {
const processCheckingForUpdates = di.inject(processCheckingForUpdatesInjectable); const withOrphanPromise = di.inject(withOrphanPromiseInjectable);
const processCheckingForUpdates = withOrphanPromise(di.inject(processCheckingForUpdatesInjectable));
return getStartableStoppable("periodical-check-for-updates", () => { return getStartableStoppable("periodical-check-for-updates", () => {
const TWO_HOURS = 1000 * 60 * 60 * 2; const TWO_HOURS = 1000 * 60 * 60 * 2;
// Note: intentional orphan promise to make checking for updates happen in the background
processCheckingForUpdates("periodic"); processCheckingForUpdates("periodic");
const intervalId = setInterval(() => { const intervalId = setInterval(() => {
// Note: intentional orphan promise to make checking for updates happen in the background
processCheckingForUpdates("periodic"); processCheckingForUpdates("periodic");
}, TWO_HOURS); }, TWO_HOURS);