From 14d9df31cc8a5954e23d2f1ed0120a0827d63787 Mon Sep 17 00:00:00 2001 From: Local Dev Date: Sun, 4 Oct 2026 01:50:31 +0200 Subject: [PATCH] =?UTF-8?q?fix(theseus/error):=20show=20branded=20error=20?= =?UTF-8?q?page=20on=20BCNR=E2=86=92clearnet=20fallback=20failures?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit flytastic.ru (and any other site where the BCNR lookup NXDOMAINs and the clearnet fallback fails with a cert / network error) was leaving the tab blank instead of showing the error page. Cause — tab.internalNav was overloaded. loadBns's fallbackToWeb sets internalNav=true before loadURL("https://host/") so will-navigate doesn't re-route the programmatic nav back through navigateTab. The did-fail-load handler was using the SAME flag to suppress recursion on its own loadFile(error.html) call — so a cert error during the clearnet fallback was silently swallowed. Narrow the suppression to its real target: skip did-fail-load only when the failing URL is file:// (our own error.html / home.html loads). Clearnet HTTPS failures from a programmatic loadURL now surface the branded error page like any other failed navigation. The will-navigate guard (its original purpose) is untouched. --- main.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/main.js b/main.js index 5b7e1b1c..d8a1a439 100644 --- a/main.js +++ b/main.js @@ -4013,13 +4013,18 @@ function createTab(initial, opts = {}) { wc.on("did-finish-load", () => { if (!tab.settings && !tab.addonId) webapps.probeTab(tab).then(() => { if (tab.id === activeId) emitTabs(); }).catch(() => {}); }); // Failed loads: NAME_NOT_RESOLVED, CONNECTION_REFUSED, cert errors, etc. // Show the branded error page instead of Chromium's default "This site - // can't be reached". Skip subframe errors, our own programmatic loads, - // and the couple of Chromium codes that fire on normal user actions - // (Stop / superseded nav / extension cancel). + // can't be reached". Skip subframe errors and the couple of Chromium + // codes that fire on normal user actions (Stop / superseded nav / + // extension cancel). Also skip failures of our own file:// loads + // (error.html / home.html) to avoid recursion — but DO handle failures + // of programmatic loadURL calls to clearnet (BNS fallbackToWeb sets + // internalNav to block will-navigate re-entry, not to swallow errors; + // without this, a cert-expired or unreachable upstream after a failed + // BNS lookup leaves the tab blank). wc.on("did-fail-load", (_e, code, desc, validatedURL, isMainFrame) => { if (!isMainFrame) return; - if (tab.internalNav) return; if (ERROR_CODE_IGNORE.has(code)) return; + if (typeof validatedURL === "string" && validatedURL.startsWith("file://")) return; loadErrorPage(tab, tab.id, { url: validatedURL || tab.url, code, desc }); }); // Firefox / Chrome-style bottom-left link preview: fires with the href