Skip to content

Commit 97d152e

Browse files
elias-didooYun Xiaojackwener
authored
fix: retry on No window with id CDP error (#892)
* fix: retry on No window with id CDP error * test(browser): lock transient window-id retry behavior --------- Co-authored-by: Yun Xiao <yunxiao@agents.com> Co-authored-by: jackwener <jakevingoo@gmail.com>
1 parent 0b11a1e commit 97d152e

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

extension/src/cdp.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,10 @@ export async function ensureAttached(tabId: number, aggressiveRetry: boolean = f
9292
break; // Don't retry if URL became un-debuggable
9393
}
9494
} catch {
95+
// Tab is gone — don't fail early here.
96+
// Later retry layers can re-resolve a fresh automation tab/window.
9597
lastError = `Tab ${tabId} no longer exists`;
96-
break;
98+
// Don't break; fall through to retry
9799
}
98100
}
99101
}

src/browser/errors.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { describe, expect, it } from 'vitest';
2+
3+
import { isTransientBrowserError } from './errors.js';
4+
5+
describe('isTransientBrowserError', () => {
6+
it('treats "No window with id" as transient', () => {
7+
expect(isTransientBrowserError(new Error('No window with id: 123'))).toBe(true);
8+
});
9+
10+
it('does not classify unrelated browser errors as transient', () => {
11+
expect(isTransientBrowserError(new Error('Permission denied'))).toBe(false);
12+
});
13+
});

src/browser/errors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const TRANSIENT_ERROR_PATTERNS = [
2020
'no longer exists',
2121
'CDP connection',
2222
'Daemon command failed',
23+
'No window with id',
2324
] as const;
2425

2526
/**

0 commit comments

Comments
 (0)