From 0b955cb95473019aff084689c3c3579898bf7f8c Mon Sep 17 00:00:00 2001 From: Daniel Andrei Date: Wed, 17 Apr 2019 09:45:22 +0300 Subject: [PATCH] Fix error on quit caused by Electron race issue (#811) Fixes #809 Co-authored-by: Sindre Sorhus --- source/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/index.ts b/source/index.ts index c7f30f856..506f4607e 100644 --- a/source/index.ts +++ b/source/index.ts @@ -459,7 +459,12 @@ app.on('activate', () => { app.on('before-quit', () => { isQuitting = true; - config.set('lastWindowState', mainWindow.getNormalBounds()); + + // Checking whether the window exists to work around an Electron race issue: + // https://github.com/sindresorhus/caprine/issues/809 + if (mainWindow) { + config.set('lastWindowState', mainWindow.getNormalBounds()); + } }); const notifications = new Map();