Skip to content

Commit c9c2d72

Browse files
fix(browser): tolerate an unparsable initial URL and trim redundant Stop cases
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent dd6a975 commit c9c2d72

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

‎apps/server/src/preview/ServerBrowser.test.ts‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ it.effect("a desktop page that loaded before the server attached reports its loa
998998
).pipe(Effect.provide(layer)),
999999
);
10001000

1001-
it.effect.each(["none", "during", "after", "after-fragment", "corrected", "same-url"])(
1001+
it.effect.each(["none", "during", "after-fragment", "same-url"])(
10021002
"Stop settles an initial navigation with its request event $0",
10031003
(requestTiming) =>
10041004
Effect.scoped(
@@ -1056,16 +1056,15 @@ it.effect.each(["none", "during", "after", "after-fragment", "corrected", "same-
10561056
) {
10571057
settled = yield* PubSub.take(events);
10581058
}
1059-
const corrected = requestTiming === "corrected" || requestTiming === "same-url";
1059+
const corrected = requestTiming === "same-url";
10601060
using timeout = vi.spyOn(globalThis, "setTimeout");
10611061
if (corrected) {
1062-
const url = requestTiming === "same-url" ? request.url() : "https://example.com/fixed";
10631062
page.goto.mockImplementationOnce(async () => {
1064-
page.emit("request", { ...request, url: () => url });
1063+
page.emit("request", request);
10651064
});
1066-
yield* viewer.input({ type: "navigate", url });
1065+
yield* viewer.input({ type: "navigate", url: request.url() });
10671066
} else if (requestTiming !== "none") {
1068-
if (requestTiming.startsWith("after")) page.emit("request", request);
1067+
if (requestTiming === "after-fragment") page.emit("request", request);
10691068
page.emit("requestfailed", request);
10701069
}
10711070
const status = yield* broker.invoke<PreviewAutomationStatus>({

‎apps/server/src/preview/ServerBrowser.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,9 +1176,9 @@ const make = Effect.gen(function* () {
11761176
((!adopted && !desktop) || isPdfAssetUrl(snapshot.navStatus.url))
11771177
) {
11781178
tab.loading = true;
1179-
const initialUrl = new URL(snapshot.navStatus.url);
1180-
initialUrl.hash = "";
1181-
tab.pendingInitialRequestUrl = initialUrl.href;
1179+
const initialUrl = URL.parse(snapshot.navStatus.url);
1180+
if (initialUrl) initialUrl.hash = "";
1181+
tab.pendingInitialRequestUrl = initialUrl?.href ?? null;
11821182
const options = { waitUntil: "commit", timeout: NAVIGATION_TIMEOUT_MS } as const;
11831183
tab.initialNavigation = (
11841184
(desktop || adopted) && page.url() === snapshot.navStatus.url

0 commit comments

Comments
 (0)