Skip to content

Commit

Permalink
fix(backend): wait until quit to close backend
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
b5 authored and ramfox committed Sep 12, 2019
1 parent d925811 commit 4b330da
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/main.development.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -95,8 +102,6 @@ app.on('ready', () =>

mainWindow.on('closed', () => {
mainWindow = null
backendProcess.close()
backendProcess = null
})

if (process.env.NODE_ENV === 'development') {
Expand Down

0 comments on commit 4b330da

Please sign in to comment.