fix(server,desktop): browser tools report why a page failed to load#18588

open6
main
GitHub fork: feat/preview-load-error-v2
opened11d agobyRrobertnisipeanu
View on GitHubTwo-way sync enabledPR last imported 19h ago
Selected thread: apps/server/src/preview/ServerBrowser.ts:1358 — Verified against the current code and Playwright 1.60: the proposed ordering does not produce the reported omission. `loadErrorOf` only reads a diagnostic once Playwright's URL is `chrome-error://`. For an observed navigation, Playwright processes `Network.loadingFailed` into `requestfailed` before the error-page frame navigation updates that URL, on the same CDP stream. The handler has already populated `tab.loadError` at that point. Superseded requests are intentionally ignored; aborted requests are also excluded by Electron's failure forwarding. The desktop fallback covers failure before CDP attachment. Accepting its cached value after an observed navigation would restore the stale pre-attachment diagnostic covered by the existing desktop regression. The real-Chromium failure transcripts also confirm the server's own handler supplies diagnostics after the error page appears. No code change.
0 / 9 viewed9 files changedLine totals unavailable

apps/desktop/src/preview/DesktopBrowserHost.ts · Earlier revision ea692c64 · right 195–196

Original diff
@@ -187,6 +192,10 @@ export const make = Effect.gen(function* () {
     emit({ type: "attached", ...key });
   };
 
+  const loadFailed: DesktopBrowserHost["Service"]["loadFailed"] = (key, failure) => {
+    if (tabs.has(keyOf(key))) emit({ type: "loadFailed", ...key, ...failure });

apps/desktop/src/preview/DesktopBrowserHost.ts · right 195–196

apps/server/src/preview/ServerBrowser.ts · Earlier revision ea692c64 · right 1326–1327

Original diff
@@ -1312,6 +1316,19 @@ const make = Effect.gen(function* () {
     );
   };
 
+  /**
+   * Why the tab shows the browser's error page. A desktop tab's first load can
+   * fail before this server connects, so the desktop's own report fills in.
+   */
+  const loadErrorOf = async (tab: ServerTab) => {
+    if (!tab.page.url().startsWith("chrome-error://")) return undefined;
+    if (tab.loadError !== undefined || !tab.desktop) return tab.loadError ?? undefined;
+    const reported = await Effect.runPromise(
+      desktopChannel.loadFailure({ threadId: tab.threadId, tabId: tab.tabId }),

apps/server/src/preview/ServerBrowser.ts · right 1326–1327