Closed
Description
Attempting to close a window immediately after receiving a did-fail-load
event crashes Electron. There's an easy workaround (delaying the close operation in a setTimeout
fixes the crash).
I created a minimal repro, but for clarity, here's what's happening:
app.on('ready', () => {
const win = new BrowserWindow({})
win.webContents.on('did-fail-load', () => {
win.close()
// If you call this instead, we'll be alright - and the
// interval below will prove it
// setTimeout(() => win.close(), 1000)
})
win.loadURL('https://i-do-not-exist')
})
app.on('window-all-closed', () => {
setInterval(() => console.log('Still alive!'), 500)
console.log(`If you're not seeing a "still alive" printed, we're dead :(`)
})
- Electron version: 1.6.1, 1.6.2 and later
- Operating system: proven on macOS, reports from Windows
Expected behavior
Electron should not crash
Actual behavior
Electron crashes
How to reproduce
git clone https://github.com/felixrieseberg/electron-close-crash
npm install
npm start