From dacbee711f3c7cae5309f08e3f685a496f48ab99 Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Mon, 20 Jun 2022 10:43:15 -0700 Subject: [PATCH] Polyfill os.hostname() on Windows 7 --- app/main.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/main.ts b/app/main.ts index a5853af23..f6b50fccc 100644 --- a/app/main.ts +++ b/app/main.ts @@ -396,6 +396,16 @@ async function prepareUrl( ); } + let hostname: string; + + try { + // os.hostname() doesn't work on Windows 7 anymore + // See: https://github.com/electron/electron/issues/34404 + hostname = os.hostname(); + } catch { + hostname = 'Desktop'; + } + const urlParams: RendererConfigType = { name: packageJson.productName, locale: getLocale().name, @@ -411,7 +421,7 @@ async function prepareUrl( environment: enableCI ? Environment.Production : getEnvironment(), enableCI, nodeVersion: process.versions.node, - hostname: os.hostname(), + hostname, appInstance: process.env.NODE_APP_INSTANCE || undefined, proxyUrl: process.env.HTTPS_PROXY || process.env.https_proxy || undefined, contentProxyUrl: config.get('contentProxyUrl'),