Skip to content

Commit 1678414

Browse files
fix(server): the navigation probe leaves goto half its budget
An unanswered probe could spend the whole budget when it was 1s or less, leaving goto 1 ms. A cross-site navigation, which leaves a hung page by itself, then failed where main succeeded. AI-assisted; verified with the tests and tools listed above. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent dda7a4d commit 1678414

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,9 +1015,10 @@ it.live.each(["load", "none"] as const)(
10151015

10161016
expect(status.url).toBe("http://localhost:5173/next");
10171017
expect(navigated).toMatchObject({ _tag: "Success" });
1018-
// Waiting on the busy script spends the navigation's own budget.
1018+
// Waiting on the busy script spends half the navigation's own budget, not all of it.
10191019
const [, gotoOptions] = contexts[0]!.page.goto.mock.calls.at(-1)!;
10201020
expect(gotoOptions?.timeout).toBeLessThan(200);
1021+
expect(gotoOptions?.timeout).toBeGreaterThan(1);
10211022
expect(waited).toMatchObject({ _tag: "Success" });
10221023
}),
10231024
).pipe(Effect.provide(layer)),

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1785,7 +1785,8 @@ const make = Effect.gen(function* () {
17851785
timeout: number,
17861786
) => {
17871787
const probeStartedAt = performance.now();
1788-
await ServerBrowserPage.stopUnresponsiveScript(tab.cdp, timeout);
1788+
// Half the budget at most: a cross-site goto leaves a hung page by itself and needs the rest.
1789+
await ServerBrowserPage.stopUnresponsiveScript(tab.cdp, timeout / 2);
17891790
const navigation = tab.page.goto(url, {
17901791
// The probe spends the caller's budget; the broker evicts a host that answers late.
17911792
timeout: Math.max(1, timeout - (performance.now() - probeStartedAt)),

0 commit comments

Comments
 (0)