The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 07:15 UTC
fix(server): a preview navigation request issued before its frame exists no longer crashes the server (#30946)
Co-authored-by: Isaac-b-ux <264455269+Isaac-b-ux@users.noreply.github.com> Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>
Isaac-b-ux committed
Nov 18, 2026 at 04:39 UTC
ce884e3a9d11ec46a31aa6ee7c5838dac76f3d02
2 files changed
+43
-2
apps/server/src/preview/ServerBrowser.test.ts
+34
@@ -2111,6 +2111,40 @@ it.effect(
2111
).pipe(Effect.provide(layer)),
2112
);
2113
2114
+it.effect("a request whose frame is not available yet is not a main navigation", () =>
2115
+ Effect.scoped(
2116
+ Effect.gen(function* () {
2117
+ const { broker, tabId } = yield* ready;
2118
+ const page = contexts[0]!.page;
2119
+ const frameless = {
2120
+ url: () => "https://example.com/early",
2121
+ method: () => "GET",
2122
+ isNavigationRequest: () => true,
2123
+ frame: () => {
2124
+ throw new Error("Frame for this navigation request is not available");
2125
+ },
2126
+ failure: () => ({ errorText: "net::ERR_CONNECTION_REFUSED" }),
2127
+ };
2128
+ expect(() => page.emit("request", frameless)).not.toThrow();
2129
+ const statusAfterRequest = yield* broker.invoke<PreviewAutomationStatus>({
2130
+ scope,
2131
+ tabId,
2132
+ operation: "status",
2133
+ input: {},
2134
+ });
2135
+ expect(statusAfterRequest.loading).toBe(false);
2136
+ expect(() => page.emit("requestfailed", frameless)).not.toThrow();
2137
+ const status = yield* broker.invoke<PreviewAutomationStatus>({
2138
+ scope,
2139
+ tabId,
2140
+ operation: "status",
2141
+ input: {},
2142
+ });
2143
+ expect(status.loading).toBe(false);
2144
+ }),
2145
+ ).pipe(Effect.provide(layer)),
2146
+);
2147
+
2148
it.effect.each(["before", "during"] as const)(
2149
"a navigation that fails while a load reads its title keeps its failure (request %s read)",
2150
(requestTiming) =>
apps/server/src/preview/ServerBrowser.ts
+9
-2
@@ -1234,8 +1234,15 @@ const make = Effect.gen(function* () {
1234
});
1235
await cdp.send("Page.enable");
1236
}
1237
- const isMainNavigation = (request: { isNavigationRequest(): boolean; frame(): unknown }) =>
1238
- request.isNavigationRequest() && request.frame() === page.mainFrame();
1237
+ // Playwright's `request.frame()` throws for a request issued before its frame exists, and a
1238
+ // throw from a page listener is uncaught, so such a request is not a main-frame navigation.
1239
+ const isMainNavigation = (request: { isNavigationRequest(): boolean; frame(): unknown }) => {
1240
+ try {
1241
+ return request.isNavigationRequest() && request.frame() === page.mainFrame();
1242
+ } catch {
1243
+ return false;
1244
+ }
1245
+ };
1246
const navigationGenerations = new WeakMap<object, number>();
1247
page.on("request", (request) => {
1248
if (!isMainNavigation(request)) return;