Skip to content

Commit d67f5ac

Browse files
committed
fix(browser-protocol): widen the renderer's wait grace to cover the closing snapshot
1 parent 70882e6 commit d67f5ac

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

‎apps/desktop/src/main/browser-agent/driver.test.ts‎

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3100,28 +3100,27 @@ describe('credential protection', () => {
31003100

31013101
it('gives a wait that runs to its timeout a full snapshot budget for its closing observation', async () => {
31023102
const contents = await openPage()
3103+
let finishSnapshot: (value: unknown) => void = () => {}
31033104
vi.mocked(contents.executeJavaScript).mockImplementation((expression: string) => {
31043105
if (!isPageCall(expression, 'collectSnapshot')) return Promise.resolve(undefined)
3105-
return new Promise((resolve) =>
3106-
setTimeout(
3107-
() =>
3108-
resolve({
3109-
url: 'https://example.com/',
3110-
title: 'Example',
3111-
outline: '- heading "Order confirmed"',
3112-
truncated: false,
3113-
refIds: [],
3114-
refLineIndexes: {},
3115-
nextElementId: 1_000,
3116-
}),
3117-
8_000
3118-
)
3119-
)
3106+
return new Promise((resolve) => {
3107+
finishSnapshot = resolve
3108+
})
31203109
})
31213110
vi.useFakeTimers()
31223111
try {
31233112
const waiting = driver.executeTool('chat-test', 'browser_wait_for', { timeoutMs: 1_000 })
3124-
await vi.advanceTimersByTimeAsync(30_000)
3113+
await vi.advanceTimersByTimeAsync(9_000)
3114+
finishSnapshot({
3115+
url: 'https://example.com/',
3116+
title: 'Example',
3117+
outline: '- heading "Order confirmed"',
3118+
truncated: false,
3119+
refIds: [],
3120+
refLineIndexes: {},
3121+
nextElementId: 1_000,
3122+
})
3123+
await vi.advanceTimersByTimeAsync(1_000)
31253124

31263125
expect(await waiting).toMatchObject({
31273126
ok: true,

‎packages/browser-protocol/src/index.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ export type BrowserToolName = (typeof BROWSER_TOOL_NAMES)[number]
6565

6666
const BROWSER_WAIT_FOR_DEFAULT_TIMEOUT_MS = 10_000
6767
const BROWSER_WAIT_FOR_MAX_TIMEOUT_MS = 120_000
68-
const BROWSER_WAIT_FOR_RENDERER_GRACE_MS = 15_000
68+
/** Covers the desktop's wait grace and the snapshot a wait ends with (25s), plus transport. */
69+
const BROWSER_WAIT_FOR_RENDERER_GRACE_MS = 30_000
6970
export const BROWSER_TOOL_AUTHORIZATION_TIMEOUT_MS = 8_000
7071
export const BROWSER_NAVIGATION_NATIVE_WATCHDOG_MS = 60_000
7172
export const BROWSER_TOOL_QUEUE_WAIT_TIMEOUT_MS = BROWSER_NAVIGATION_NATIVE_WATCHDOG_MS

0 commit comments

Comments
 (0)