···13351335});
1336133613371337webview.addEventListener('did-fail-load', (e) => {
13381338+ if (!e.isMainFrame) return;
13391339+13381340 if (e.errorCode === -3) {
13391339- // Error -3 (ABORTED) normally fires during legitimate re-navigation and is safe to ignore.
13401340- // However, if no page has ever loaded (e.g. URL triggered a download instead),
13411341- // the window is stuck in loading state forever — clear it.
13421342- if (!hasEverLoaded) {
13431343- console.log('[page] Load aborted before any page loaded (likely download), clearing loading state');
13441344- loadingLifecycle.stopLoading();
13451345- }
13411341+ // Error -3 (ABORTED) fires during legitimate re-navigation (e.g. clicking a link
13421342+ // while a page is loading) AND for cancelled navigations (downloads, window.stop(),
13431343+ // intercepted popups, etc.). Always clear loading state — if a new navigation is
13441344+ // starting, did-start-navigation will immediately re-enter startLoading().
13451345+ console.log('[page] Load aborted (error -3), clearing loading state');
13461346+ loadingLifecycle.stopLoading();
13461347 return;
13471348 }
13481349 console.error('[page] Load failed:', e.errorCode, e.errorDescription);