Electron v5.0.0-beta.6 will likely break every single page application / SPA that uses routing as it's uncommon to trigger the routing only after the page loading event has been fired. See workaround in additional Information section below.
Issue Details
- Electron Version:
- Operating System:
- Last Known Working Electron version:
Expected Behavior
Page loading completes without errors even if that's a SPA.
Actual Behavior
window.location.hash = '123' called on page:
{ Error: ERR_ABORTED (-3) loading 'file:////dev/temp/electron-loadurl-issue/page.html#123'
at rejectAndCleanup (//dev/temp/electron-loadurl-issue/node_modules/electron/dist/resources/electron.asar/browser/navigation-controller.js:72:21)
at WebContents.navigationListener (//dev/temp/electron-loadurl-issue/node_modules/electron/dist/resources/electron.asar/browser/navigation-controller.js:93:20)
at WebContents.emit (events.js:193:15)
errno: -3,
code: 'ERR_ABORTED',
url:
'file:////dev/temp/electron-loadurl-issue/page.html#123' }
history.pushState({}, "title", "url") called on page:
{ Error: ERR_ABORTED (-3) loading 'file:////dev/temp/electron-loadurl-issue/url'
at rejectAndCleanup (//dev/temp/electron-loadurl-issue/node_modules/electron/dist/resources/electron.asar/browser/navigation-controller.js:72:21)
at WebContents.navigationListener (//dev/temp/electron-loadurl-issue/node_modules/electron/dist/resources/electron.asar/browser/navigation-controller.js:93:20)
at WebContents.emit (events.js:193:15)
errno: -3,
code: 'ERR_ABORTED',
url: 'file:////dev/temp/electron-loadurl-issue/url' }
To Reproduce
const path = require("path");
const url = require("url");
const {app, BrowserWindow} = require("electron");
app.on("ready", async () => {
const browserWindow = new BrowserWindow();
browserWindow.webContents.on("did-start-navigation", (event, url) => {
console.log("did-start-navigation", {url});
});
try {
await browserWindow.loadURL(
url.format({
protocol: "file",
slashes: true,
pathname: path.join(__dirname, "page.html")
})
);
} catch (e) {
console.error(e);
}
// "loadFile" gives the same result
// try {
// await browserWindow.loadFile(
// path.join(__dirname, "page.html"),
// );
// } catch (e) {
// console.error(e);
// }
});
<!DOCTYPE html>
<html>
<body>
<script>
window.location.hash = '123';
// history.pushState({}, "title", "url"); // second case
</script>
</body>
</html>
Screenshots
N/A
Additional Information
The workaround is changing the hash / history state afte page got loaded:
<!DOCTYPE html>
<html>
<script>
function onload() {
window.location.hash = '123';
// history.pushState({}, "title", "url"); // second case
}
</script>
<body onload="onload">
</body>
</html>
See relater PR #15855 and code line https://github.com/electron/electron/pull/15855/files#diff-fc5b6704bed639bfab5927de1eccbcc3R85
CC @nornagon
Electron v5.0.0-beta.6 will likely break every single page application / SPA that uses routing as it's uncommon to trigger the routing only after the page loading event has been fired. See workaround in additional Information section below.
Issue Details
Expected Behavior
Page loading completes without errors even if that's a SPA.
Actual Behavior
window.location.hash = '123'called on page:history.pushState({}, "title", "url")called on page:To Reproduce
Screenshots
N/A
Additional Information
The workaround is changing the hash / history state afte page got loaded:
See relater PR #15855 and code line https://github.com/electron/electron/pull/15855/files#diff-fc5b6704bed639bfab5927de1eccbcc3R85
CC @nornagon