Skip to content

Commit a99f59c

Browse files
authored
Fix: check command hangs indefinitely (#272)
Fixes #257
1 parent 45506fb commit a99f59c

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/actions.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,14 @@ export function toAIFriendlyError(error: unknown, selector: string): Error {
177177
);
178178
}
179179

180+
// Handle general timeout (element exists but action couldn't complete)
181+
if (message.includes('Timeout') && message.includes('exceeded')) {
182+
return new Error(
183+
`Action on "${selector}" timed out. The element may be blocked, still loading, or not interactable. ` +
184+
`Run 'snapshot' to check the current page state.`
185+
);
186+
}
187+
180188
// Handle element not found (timeout waiting for element)
181189
if (
182190
message.includes('waiting for') &&

src/browser.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ describe('BrowserManager', () => {
402402
{ url: () => 'http://anothersite.com', on: vi.fn() },
403403
],
404404
on: vi.fn(),
405+
setDefaultTimeout: vi.fn(),
405406
},
406407
],
407408
close: vi.fn(),

src/browser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,7 @@ export class BrowserManager {
10291029
this.cdpEndpoint = cdpEndpoint;
10301030

10311031
for (const context of contexts) {
1032+
context.setDefaultTimeout(10000);
10321033
this.contexts.push(context);
10331034
this.setupContextTracking(context);
10341035
}

0 commit comments

Comments
 (0)