@devries-cameron20 / t3code-1 / commits / cb7fb7a493
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): a preview navigation that fails mid-load keeps its failure (#27537)

Co-authored-by: maria-rcks <maria@kuuro.net>

Cameron Chisholm committed Nov 1, 2026 at 21:46 UTC cb7fb7a493370b3167e23009459b9a8d3390dcdb
2 files changed +46 -1
apps/server/src/preview/ServerBrowser.test.ts
+43
@@ -1018,6 +1018,49 @@ it.live(
1018 ).pipe(Effect.provide(layer)),
1019 );
1020
1021 +it.effect("a navigation that fails while a load reads its title keeps its failure", () =>
1022 + Effect.scoped(
1023 + Effect.gen(function* () {
1024 + const { tabId } = yield* ready;
1025 + const manager = yield* Manager.PreviewManager;
1026 + const events = yield* manager.subscribeEvents;
1027 + const page = contexts[0]!.page;
1028 + const heldTitle = Promise.withResolvers<string>();
1029 + page.title.mockImplementationOnce(() => heldTitle.promise);
1030 + yield* Effect.promise(() => page.goto("https://example.com/first"));
1031 + const failing = {
1032 + url: () => "https://example.com/missing",
1033 + method: () => "GET",
1034 + isNavigationRequest: () => true,
1035 + frame: () => page,
1036 + failure: () => ({ errorText: "net::ERR_NAME_NOT_RESOLVED" }),
1037 + };
1038 + page.emit("request", failing);
1039 + page.emit("requestfailed", failing);
1040 + heldTitle.resolve("Held");
1041 + // A load at the same await depth reports after the held one, so its Success marks the end.
1042 + page.emit("load");
1043 +
1044 + const statuses: Array<string> = [];
1045 + while (!statuses.at(-1)?.startsWith("Success")) {
1046 + const event = yield* PubSub.take(events);
1047 + if (event.type === "failed" && event.tabId === tabId) {
1048 + statuses.push(`LoadFailed ${event.url}`);
1049 + } else if (event.type === "navigated" && event.tabId === tabId) {
1050 + const status = event.snapshot.navStatus;
1051 + if (status._tag === "Success") statuses.push(`Success ${status.title}`);
1052 + else if (status._tag === "Loading") statuses.push(`Loading ${status.url}`);
1053 + }
1054 + }
1055 + expect(statuses).toEqual([
1056 + "Loading https://example.com/missing",
1057 + "LoadFailed https://example.com/missing",
1058 + "Success test page",
1059 + ]);
1060 + }),
1061 + ).pipe(Effect.provide(layer)),
1062 +);
1063 +
1064 it.effect.each([
1065 {
1066 name: "hover burst before a click",
apps/server/src/preview/ServerBrowser.ts
+3 -1
@@ -590,8 +590,10 @@ const make = Effect.gen(function* () {
590 const url = tab.page.url();
591 // Chromium's error page loads after `requestfailed` and must not clear LoadFailed.
592 if (url === "about:blank" || url.startsWith("chrome-error://")) return;
593 + // A navigation that starts and fails during the title read leaves the URL unchanged.
594 + const generation = tab.navigationGeneration;
595 const title = (await tab.page.title().catch(() => "")).slice(0, 512);
594 - if (tab.loading || tab.page.url() !== url) return;
596 + if (tab.navigationGeneration !== generation || tab.loading || tab.page.url() !== url) return;
597 report(tab, {
598 _tag: "Success",
599 url: ServerBrowserPage.withoutDataPayload(url).slice(0, 2048),