From 62f91547c36e8f9637d3151e6364d9abd1627e01 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Thu, 18 Jun 2020 20:57:44 -0300 Subject: [PATCH] Fix #258: Fixing crash when changing network while opening TTL --- main.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/main.js b/main.js index 63c27c376..bd4b433da 100644 --- a/main.js +++ b/main.js @@ -39,6 +39,14 @@ var launchDate = new Date(); var recommendPunchIn = false; setTimeout(() => { recommendPunchIn = true; }, 30 * 60 * 1000); +process.on('uncaughtException', function(err) { + if (!err.message.includes('net::ERR_NETWORK_CHANGED')) { + console.error((new Date).toUTCString() + ' uncaughtException:', err.message); + console.error(err.stack); + process.exit(1); + } +}); + function checkIdleAndNotify() { if (recommendPunchIn) { recommendPunchIn = false; @@ -130,7 +138,7 @@ function createWindow() { const today = new Date(); global.waiverDay = getDateStr(today); } - const htmlPath = path.join('file://', __dirname, 'src/workday-waiver.html'); + const htmlPath = path.join(__dirname, 'src/workday-waiver.html'); waiverWindow = new BrowserWindow({ width: 600, height: 500, parent: win, @@ -141,7 +149,7 @@ function createWindow() { nodeIntegration: true } }); waiverWindow.setMenu(null); - waiverWindow.loadURL(htmlPath); + waiverWindow.loadFile(htmlPath); waiverWindow.show(); waiverWindow.on('close', function() { waiverWindow = null; @@ -192,7 +200,7 @@ function createWindow() { return; } - const htmlPath = path.join('file://', __dirname, 'src/preferences.html'); + const htmlPath = path.join(__dirname, 'src/preferences.html'); prefWindow = new BrowserWindow({ width: 400, height: 500, parent: win, @@ -203,7 +211,7 @@ function createWindow() { nodeIntegration: true } }); prefWindow.setMenu(null); - prefWindow.loadURL(htmlPath); + prefWindow.loadFile(htmlPath); prefWindow.show(); //prefWindow.webContents.openDevTools() prefWindow.on('close', function() {