Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: crash when destroying node env with pending promises (#33302)
* fix: crash when destroying node env with pending promises * chore: add spec Co-authored-by: deepak1556 <hop2deep@gmail.com>
- Loading branch information
1 parent
fc3172d
commit 91274e5
Showing
4 changed files
with
64 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
spec-main/fixtures/crash-cases/fs-promises-renderer-crash/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<html> | ||
<body> | ||
<script> | ||
const fs = require('fs'); | ||
const { ipcRenderer } = require('electron'); | ||
|
||
async function readFile(path) { | ||
await fs.promises.readFile(path); | ||
} | ||
|
||
ipcRenderer.on('reload', (_, path) => { | ||
readFile(path); | ||
window.location.reload(); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
28 changes: 28 additions & 0 deletions
28
spec-main/fixtures/crash-cases/fs-promises-renderer-crash/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const { app, BrowserWindow, ipcMain } = require('electron'); | ||
const path = require('path'); | ||
|
||
app.whenReady().then(() => { | ||
let reloadCount = 0; | ||
const win = new BrowserWindow({ | ||
show: false, | ||
webPreferences: { | ||
nodeIntegration: true, | ||
contextIsolation: false | ||
} | ||
}); | ||
|
||
win.loadFile('index.html'); | ||
|
||
win.webContents.on('render-process-gone', () => { | ||
process.exit(1); | ||
}); | ||
|
||
win.webContents.on('did-finish-load', () => { | ||
if (reloadCount > 2) { | ||
setImmediate(() => app.quit()); | ||
} else { | ||
reloadCount += 1; | ||
win.webContents.send('reload', path.join(__dirname, '..', '..', 'cat.pdf')); | ||
} | ||
}); | ||
}); |