diff --git a/src/main/CriticalErrorHandler.js b/src/main/CriticalErrorHandler.js index 54965f52..383ae8be 100644 --- a/src/main/CriticalErrorHandler.js +++ b/src/main/CriticalErrorHandler.js @@ -1,4 +1,5 @@ -const {app, dialog, shell} = require('electron'); +const {app, dialog} = require('electron'); +const {spawn} = require('child_process'); const fs = require('fs'); const os = require('os'); const path = require('path'); @@ -9,6 +10,20 @@ function createErrorReport(err) { `${err.stack}`; } +function openDetachedExternal(url) { + const spawnOption = {detached: true, stdio: 'ignore'}; + switch (process.platform) { + case 'win32': + return spawn('cmd', ['/C', 'start', url], spawnOption); + case 'darwin': + return spawn('open', [url], spawnOption); + case 'linux': + return spawn('xdg-open', [url], spawnOption); + default: + return null; + } +} + function bindWindowToShowMessageBox(win) { if (win && win.isVisible()) { return dialog.showMessageBox.bind(null, win); @@ -54,7 +69,13 @@ class CriticalErrorHandler { defaultId: 0 }); if (result === 1) { - shell.openExternal(file); + const child = openDetachedExternal(file); + if (child) { + child.on('error', (spawnError) => { + console.log(spawnError); + }); + child.unref(); + } } } throw err;