From 075b968cbc43f13ba1b692194a4ea0cd8050a3d9 Mon Sep 17 00:00:00 2001 From: automated-signal <37887102+automated-signal@users.noreply.github.com> Date: Wed, 27 Apr 2022 16:43:14 -0700 Subject: [PATCH] Fix "Cannot Update" dialog's retry button Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> --- ts/updater/common.ts | 7 +++++++ ts/updater/got.ts | 21 ++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/ts/updater/common.ts b/ts/updater/common.ts index 0d0b294a8..5d1df1f1f 100644 --- a/ts/updater/common.ts +++ b/ts/updater/common.ts @@ -180,6 +180,13 @@ export abstract class Updater { const mainWindow = this.getMainWindow(); mainWindow?.webContents.send('show-update-dialog', dialogType); + + this.setUpdateListener(async () => { + this.logger.info('updater/markCannotUpdate: retrying after user action'); + + this.markedCannotUpdate = false; + await this.checkForUpdatesMaybeInstall(); + }); } // diff --git a/ts/updater/got.ts b/ts/updater/got.ts index c85e83121..9dfe6fa0d 100644 --- a/ts/updater/got.ts +++ b/ts/updater/got.ts @@ -9,9 +9,10 @@ import * as packageJson from '../../package.json'; import { getUserAgent } from '../util/getUserAgent'; import * as durations from '../util/durations'; -export const GOT_CONNECT_TIMEOUT = 5 * durations.MINUTE; -export const GOT_LOOKUP_TIMEOUT = 5 * durations.MINUTE; -export const GOT_SOCKET_TIMEOUT = 5 * durations.MINUTE; +export const GOT_CONNECT_TIMEOUT = durations.MINUTE; +export const GOT_LOOKUP_TIMEOUT = durations.MINUTE; +export const GOT_SOCKET_TIMEOUT = durations.MINUTE; +const GOT_RETRY_LIMIT = 3; export function getProxyUrl(): string | undefined { return process.env.HTTPS_PROXY || process.env.https_proxy; @@ -47,5 +48,19 @@ export function getGotOptions(): GotOptions { // This timeout is reset whenever we get new data on the socket socket: GOT_SOCKET_TIMEOUT, }, + retry: { + limit: GOT_RETRY_LIMIT, + errorCodes: [ + 'ETIMEDOUT', + 'ECONNRESET', + 'ECONNREFUSED', + 'EPIPE', + 'ENOTFOUND', + 'ENETUNREACH', + 'EAI_AGAIN', + ], + methods: ['GET', 'HEAD'], + statusCodes: [413, 429, 503], + }, }; }