From 69dae28c63441db25c4182d15898c872ee94f3b2 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Apr 2026 16:05:52 +0200 Subject: [PATCH] Fix offline crash in Electron app: guard undefined response in download HEAD request and show user-facing error (#2595) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: k9ert <117085+k9ert@users.noreply.github.com> --- pyinstaller/electron/src/download.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/pyinstaller/electron/src/download.js b/pyinstaller/electron/src/download.js index 31dbf679a..9838f2adc 100644 --- a/pyinstaller/electron/src/download.js +++ b/pyinstaller/electron/src/download.js @@ -36,10 +36,11 @@ function downloadSpecterd(specterdPath) { logger.info('Using platformName ' + platformName) download_location = getDownloadLocation(appSettings.specterdVersion, platformName) logger.info('Downloading from ' + download_location) - download(download_location, specterdPath + '.zip', function (errored) { + download(download_location, specterdPath + '.zip', function (errored, errorMsg) { if (errored == true) { updatingLoaderMsg( - `Downloading the ${appNameLower} binary from GitHub failed, could not reach the server or the file wasn't found.` + errorMsg || + `Downloading the ${appNameLower} binary from GitHub failed, could not reach the server or the file wasn't found.` ) updateSpecterdStatus(`Downloading ${appNameLower}d failed...`) return @@ -83,6 +84,21 @@ function downloadSpecterd(specterdPath) { const download = (uri, filename, callback) => { // HEAD request first request.head(uri, (err, res, body) => { + if (err || !res) { + logger.error( + `Network error while trying to download specterd: ${err ? err.message : 'No response received (offline?)'}` + ) + try { + callback( + true, + `Downloading the ${appNameLower} binary from GitHub failed: no internet connection. Please check your network and try again.` + ) + } catch (error) { + logger.error(error) + throw error + } + return + } if (res.statusCode != 404) { let receivedBytes = 0 const totalBytes = res.headers['content-length']