diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2019-04-12 17:34:25 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2019-04-12 17:34:25 +0200 |
| commit | 137e3304bdb56cfd53db3c025374916d209b6480 (patch) | |
| tree | ba1f64f5ce0dfdc2f2787512843351a459a193b8 /gui | |
| parent | ef8cb5f512f69869b0b4b8048fbeab94d10864b2 (diff) | |
| parent | 5f756c25d608d7317618900b45ce3c51a8314e7a (diff) | |
| download | mullvadvpn-137e3304bdb56cfd53db3c025374916d209b6480.tar.xz mullvadvpn-137e3304bdb56cfd53db3c025374916d209b6480.zip | |
Merge branch 'ipc-and-logging-improvements'
Diffstat (limited to 'gui')
| -rw-r--r-- | gui/scripts/serve.js | 2 | ||||
| -rw-r--r-- | gui/src/shared/ipc-event-channel.ts | 13 |
2 files changed, 12 insertions, 3 deletions
diff --git a/gui/scripts/serve.js b/gui/scripts/serve.js index 7629628aa2..e1642c5b62 100644 --- a/gui/scripts/serve.js +++ b/gui/scripts/serve.js @@ -17,7 +17,7 @@ const getClientUrl = (options) => { }; function runElectron(browserSyncUrl) { - const child = spawn(electron, ['.', '--enable-logging'], { + const child = spawn(electron, ['.'], { env: { ...{ NODE_ENV: 'development', diff --git a/gui/src/shared/ipc-event-channel.ts b/gui/src/shared/ipc-event-channel.ts index 8cf09078cd..d9f9e4c3c3 100644 --- a/gui/src/shared/ipc-event-channel.ts +++ b/gui/src/shared/ipc-event-channel.ts @@ -1,4 +1,5 @@ import { ipcMain, ipcRenderer, WebContents } from 'electron'; +import log from 'electron-log'; import * as uuid from 'uuid'; import { IGuiSettingsState } from './gui-settings-state'; @@ -333,11 +334,19 @@ function requestHandler<T>(event: string): (fn: (...args: any[]) => Promise<T>) try { const result: RequestResult<T> = { type: 'success', value: await fn(...args) }; - ipcEvent.sender.send(responseEvent, result); + if (ipcEvent.sender.isDestroyed()) { + log.debug(`Cannot send the reply for ${responseEvent} since the sender was destroyed.`); + } else { + ipcEvent.sender.send(responseEvent, result); + } } catch (error) { const result: RequestResult<T> = { type: 'error', message: error.message || '' }; - ipcEvent.sender.send(responseEvent, result); + if (ipcEvent.sender.isDestroyed()) { + log.debug(`Cannot send the reply for ${responseEvent} since the sender was destroyed.`); + } else { + ipcEvent.sender.send(responseEvent, result); + } } }); }; |
