diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2019-04-12 10:31:57 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2019-04-12 14:18:41 +0200 |
| commit | 5f756c25d608d7317618900b45ce3c51a8314e7a (patch) | |
| tree | ba1f64f5ce0dfdc2f2787512843351a459a193b8 /gui/src/shared | |
| parent | 2297fc2be0b5bd3efc2e0c1d22c9e61651ddb84d (diff) | |
| download | mullvadvpn-5f756c25d608d7317618900b45ce3c51a8314e7a.tar.xz mullvadvpn-5f756c25d608d7317618900b45ce3c51a8314e7a.zip | |
Make sure the sender is not destroyed before sending the reply
Diffstat (limited to 'gui/src/shared')
| -rw-r--r-- | gui/src/shared/ipc-event-channel.ts | 13 |
1 files changed, 11 insertions, 2 deletions
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); + } } }); }; |
