electron: [Bug]: Blank page on location change / reload if a filesystem asynchronous call was pending
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a bug report that matches the one I want to file, without success.
Electron Version
17.1.1
What operating system are you using?
Windows
Operating System Version
Windows 10 21H2
What arch are you using?
x64
Last Known Working Electron version
13.6.9
Expected Behavior
Assuming a BrowserWindow like this:
const mainWindow = new BrowserWindow({
...
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
}
})
And an asynchronous filesystem call on fs.promises API
// renderer.js
const fs = require('fs');
async function asyncStuff() {
let output = await fs.promises.readFile("datafile");
}
Then trying to reload the page when the fs asynchronous call is not finished yet will make the page fail (blank page).
// renderer.js
async function testCrash() {
asyncStuff() // No await here
window.location.reload() // Here the renderer will crash
})
I expect that the page reloads correctly.
Actual Behavior
The page is blank, and DevTools are disconnected.
Testcase Gist URL
No response
Additional Information
Notes:
- Replace the
fs.promises.readFile()byfs.readFileSync()and the page will reload fine - Replace the
fs.promises.readFile()byfs.readFile() with callbackand the page will reload fine - The bug is here also with a
window.location.href - I tried with other async api and the page works fine (like
https.get(),timers.promises.setTimeout(), orfetch())
I created a repo to reproduce the bug: https://github.com/remss/electron-issue-reload
Just run npm i && npm start then click on reloadMeWithAsyncStuff button to see the blank page.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (10 by maintainers)
@DanielMcAssey correct, it’s from a version of V8 introduced in 17.