From 4b330da697236f1710fb9c989066032ef7d7a5e1 Mon Sep 17 00:00:00 2001 From: b5 Date: Sun, 8 Sep 2019 12:15:37 -0400 Subject: [PATCH] fix(backend): wait until quit to close backend backend close listener was subscribed to the mainwindow close event. This would mean the backend is shut down whenever the window closes, which would break the app for any subsequent windows. Attaching backend closing to the lifespan of the app process with the 'will-quit' event makes more sense. --- app/main.development.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/main.development.js b/app/main.development.js index 6bd9c0b7..8cace831 100644 --- a/app/main.development.js +++ b/app/main.development.js @@ -34,6 +34,13 @@ app.on('window-all-closed', () => { if (process.platform !== 'darwin') app.quit() }) +app.on('will-quit', () => { + if (backendProcess) { + backendProcess.close() + backendProcess = null + } +}) + const installExtensions = () => { if (process.env.NODE_ENV === 'development') { const installer = require('electron-devtools-installer') // eslint-disable-line global-require @@ -95,8 +102,6 @@ app.on('ready', () => mainWindow.on('closed', () => { mainWindow = null - backendProcess.close() - backendProcess = null }) if (process.env.NODE_ENV === 'development') {