fix: add 5s timeout for initial tabs fetch during CDP connect

CDP mode on @playwright/mcp v0.0.68 hangs on browser_tabs calls.
This timeout prevents the entire connect() from blocking for 30s.
This commit is contained in:
jackwener committed 2026-03-16 01:51:22 +08:00
1 parent 4ec454530a
commit f8491f01ae
1 file changed
+2 -2
+2 -2
View File
@@ -636,9 +636,9 @@ export class PlaywrightMCP {
debugLog(`SEND: ${initializedMsg.trim()}`);
this._proc?.stdin?.write(initializedMsg);
// Get initial tab count for cleanup
// Get initial tab count for cleanup (with timeout — CDP mode may hang on browser_tabs)
debugLog('Fetching initial tabs count...');
page.tabs().then((tabs: any) => {
withTimeout(page.tabs(), 5000, 'Timed out fetching initial tabs').then((tabs: any) => {
debugLog(`Tabs response: ${typeof tabs === 'string' ? tabs : JSON.stringify(tabs)}`);
this._initialTabIdentities = extractTabIdentities(tabs);
settleSuccess(page);