Skip to content

Instantly share code, notes, and snippets.

@ckerr
Last active February 18, 2021 18:48
Show Gist options
  • Save ckerr/0c2103740da1ab3eb0d9b851faa6543b to your computer and use it in GitHub Desktop.
Save ckerr/0c2103740da1ab3eb0d9b851faa6543b to your computer and use it in GitHub Desktop.

Project to reproduce exception stack member (bug?) in Electron 11.

npm install
npm run start

will show something like:

Error: there should be stack frames here:

then either change contextIsolation to false in main.js or change electron version to 10.1.6 in package.json.

npm install
npm run start

will then show something like:

Error: there should be stack frames here: at file:///C:/dev/electron_stack_test/printstack.js:1:17

I would have expected the printouts to be the same..

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Electron stack test</title>
</head>
<body style="background: white;">
<h1>Stack</h1>
<p><script src="renderer.js"></script></p>
</body>
</html>
const { app, BrowserWindow } = require('electron')
const path = require('path')
function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
contextIsolation: true, // if set to false stack traces come back
}
})
win.loadFile('index.html')
win.webContents.openDevTools()
}
app.whenReady().then(createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
document.write((new Error('there should be stack frames here:')).stack)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment