Browse Source

fix(devtools): fix devtools startup error messages

Wait until the `dom-ready` event has fired before opening up the
devtools window. This prevents the following error message showing up
multiple times when the app starts in dev mode:

> Extension server error: Operation failed: : has no execution context

See https://github.com/electron/electron/issues/12438

Fix #499
renovate/lint-staged-8.x
Tom Kirkpatrick 7 years ago
parent
commit
68dabe2c67
No known key found for this signature in database GPG Key ID: 72203A8EC5967EA8
  1. 6
      app/main.dev.js
  2. 8
      app/menu.js

6
app/main.dev.js

@ -287,6 +287,12 @@ app.on('ready', async () => {
mainWindow.loadURL(`file://${__dirname}/dist/index.html`)
}
if (process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true') {
mainWindow.webContents.once('dom-ready', () => {
mainWindow.openDevTools()
})
}
// @TODO: Use 'ready-to-show' event
// https://github.com/electron/electron/blob/master/docs/api/browser-window.md#using-ready-to-show-event
mainWindow.webContents.on('did-finish-load', () => {

8
app/menu.js

@ -9,10 +9,6 @@ export default class MenuBuilder {
}
buildMenu() {
if (process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true') {
this.setupDevelopmentEnvironment()
}
let template
if (process.platform === 'darwin') {
@ -58,10 +54,6 @@ export default class MenuBuilder {
})
}
setupDevelopmentEnvironment() {
this.mainWindow.openDevTools()
}
buildDarwinTemplate() {
const subMenuAbout = {
label: 'Electron',

Loading…
Cancel
Save