You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: BrowserWindow#loadURL() throw an error when I load same page with different location hash #28208
It is not mentioned in the official document, it seems there is option reloadIgnoringCache.
And when I call loadURL method with option which reloadIgnoringCache set to true, It seems this error is not happen.
// this code works correct (error is not happen)mainWindow.loadURL('asset:///test.html#section2',{reloadIgnoringCache: true}).then(()=>console.log('ok')).catch(console.error);
Ah, I think this is because the loadURL promise handling expects either did-finish-load or did-fail-load to have been emitted before did-stop-loading is emitted, which doesn't happen for in-page navigations. We should be able to detect the in-page nature of the navigation and avoid emitting the error.
@nornagon As an additional case, this error seems to happen if the page code has an onbeforeunload event handler that blocks the unload. Then the same 'GUEST_VIEW_MANAGER_CALL': Error: ERR_FAILED (-2) happens and the loadURL fails.
One very crude workaround is to trigger a reload from the main thread after the attempted redirect. This will at least load the intended page with the anchors on it.
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
Instead of calling browserWindow.webContents.reloadIgnoringCache() after getting ERR_FAILED (-2) I'm using browserWindow.webContents.session.clearCache() before browserWindow.loadURL() and it seems to work fine.
Activity
nornagon commentedon Jun 29, 2021
Ah, I think this is because the
loadURLpromise handling expects eitherdid-finish-loadordid-fail-loadto have been emitted beforedid-stop-loadingis emitted, which doesn't happen for in-page navigations. We should be able to detect the in-page nature of the navigation and avoid emitting the error.Relevant code:
electron/lib/browser/api/web-contents.ts
Lines 452 to 462 in da92614
gpetrov commentedon Oct 15, 2021
@nornagon As an additional case, this error seems to happen if the page code has an
onbeforeunloadevent handler that blocks the unload. Then the same 'GUEST_VIEW_MANAGER_CALL': Error: ERR_FAILED (-2) happens and the loadURL fails.lzdyes commentedon Feb 10, 2022
Can this problem be fixed?
Rodeoclash commentedon May 18, 2022
I was tearing my hair out today with this bug getting Electron to play nicely with Keycloak. Does anybody have a workaround?
Rodeoclash commentedon May 18, 2022
One very crude workaround is to trigger a reload from the main thread after the attempted redirect. This will at least load the intended page with the anchors on it.
github-actions commentedon Oct 6, 2022
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
nbabanov commentedon Oct 7, 2022
I've just ran into the same error...
@MarshallOfSound Could you please have a look?
I reproduce it with Electron v16.2.3.
loadURL()with the same url of the loaded page + an anchor and voila.At least please make those errors catch-able in the place where
loadURL()was called.RecuencoJones commentedon Oct 27, 2025
Instead of calling
browserWindow.webContents.reloadIgnoringCache()after gettingERR_FAILED (-2)I'm usingbrowserWindow.webContents.session.clearCache()beforebrowserWindow.loadURL()and it seems to work fine.