From 801a41130e49b878e93d1b361b3fccbfe836a10b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=ABck=20V=C3=A9zien?= Date: Tue, 23 Jan 2018 15:39:11 +0100 Subject: [PATCH 1/2] Clean stuff --- src/components/Wrapper.js | 2 +- src/internals/index.js | 2 -- src/main/app.js | 2 ++ src/main/bridge.js | 17 ++++++++++++----- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/components/Wrapper.js b/src/components/Wrapper.js index 1b10d3ae..42701cc7 100644 --- a/src/components/Wrapper.js +++ b/src/components/Wrapper.js @@ -26,7 +26,7 @@ class Wrapper extends Component<{}> { render() { return ( - + {process.platform === 'darwin' && } ( diff --git a/src/internals/index.js b/src/internals/index.js index 67eabe1b..0a7408f5 100644 --- a/src/internals/index.js +++ b/src/internals/index.js @@ -4,8 +4,6 @@ import objectPath from 'object-path' process.title = `ledger-wallet-desktop-${process.env.FORK_TYPE}` -process.setMaxListeners(Infinity) - function sendEvent(type: string, data: any, options: Object = { kill: true }) { process.send({ type, data, options }) } diff --git a/src/main/app.js b/src/main/app.js index e3651213..9c4963f3 100644 --- a/src/main/app.js +++ b/src/main/app.js @@ -2,6 +2,8 @@ import { app, ipcMain, BrowserWindow } from 'electron' +process.setMaxListeners(Infinity) + // necessary to prevent win from being garbage collected let mainWindow diff --git a/src/main/bridge.js b/src/main/bridge.js index d1bb2883..065052d0 100644 --- a/src/main/bridge.js +++ b/src/main/bridge.js @@ -11,12 +11,19 @@ function onForkChannel(forkType, callType) { return (event: any, payload) => { const { type, data } = payload - const compute = fork(resolve(__dirname, `${__DEV__ ? '../../' : './'}dist/internals`), [], { + let compute = fork(resolve(__dirname, `${__DEV__ ? '../../' : './'}dist/internals`), { env: { FORK_TYPE: forkType, }, }) + const kill = () => { + if (compute) { + compute.kill('SIGINT') + compute = null + } + } + compute.send({ type, data }) compute.on('message', payload => { const { type, data, options = {} } = payload @@ -26,12 +33,12 @@ function onForkChannel(forkType, callType) { if (callType === 'sync') { event.returnValue = { type, data } } - if (options.kill) { - compute.kill() + if (options.kill && compute) { + kill() } }) - process.on('exit', () => compute.kill('SIGINT')) + process.on('exit', kill) } } @@ -41,7 +48,7 @@ ipcMain.on('accounts', onForkChannel('accounts', 'async')) const handlers = { updater: { - init: send => setupAutoUpdater(send), + init: setupAutoUpdater, }, } From 9bdabc16e0c4b706acc3578f4cfcd01e9a365801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=ABck=20V=C3=A9zien?= Date: Tue, 23 Jan 2018 16:14:35 +0100 Subject: [PATCH 2/2] setMaxListeners at 100 --- src/main/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/app.js b/src/main/app.js index 9c4963f3..63c7569d 100644 --- a/src/main/app.js +++ b/src/main/app.js @@ -2,7 +2,7 @@ import { app, ipcMain, BrowserWindow } from 'electron' -process.setMaxListeners(Infinity) +process.setMaxListeners(100) // necessary to prevent win from being garbage collected let mainWindow