Skip to content

feat: add --skipUnresponsiveTabs flag for connecting to browsers with many tabs#1804

Open
jaidhyani wants to merge 1 commit intoChromeDevTools:mainfrom
jaidhyani:fix/tolerant-page-enumeration
Open

feat: add --skipUnresponsiveTabs flag for connecting to browsers with many tabs#1804
jaidhyani wants to merge 1 commit intoChromeDevTools:mainfrom
jaidhyani:fix/tolerant-page-enumeration

Conversation

@jaidhyani
Copy link
Copy Markdown

@jaidhyani jaidhyani commented Apr 2, 2026

browser.pages() hangs forever if any tab is unresponsive (discarded, sleeping, dead localhost). This is common when connecting to a daily-driver browser with 20+ tabs via --browserUrl.

Root cause: puppeteer.connect() has no protocolTimeout, and browser.pages() tries to attach to every target. One bad tab blocks everything.

This adds --skipUnresponsiveTabs (default: false). When on:

  • Sets protocolTimeout: 15s on connect
  • If browser.pages() times out (10s), falls back to per-target enumeration with 5s individual timeouts
  • Skips unresponsive tabs and logs them

Flag off = no behavior change.

Hit this on Brave 145 (28 tabs, 5 discarded). Brave is more aggressive about discarding than Chrome but the fix isn't browser-specific.

Related: puppeteer/puppeteer#5633, puppeteer/puppeteer#14708, #870, #978

@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 2, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@jaidhyani jaidhyani force-pushed the fix/tolerant-page-enumeration branch 3 times, most recently from 2f32f29 to c29e1e6 Compare April 3, 2026 01:16
@jaidhyani jaidhyani changed the title fix: tolerate unresponsive tabs when connecting to existing browser feat: add --skipUnresponsiveTabs flag for connecting to browsers with many tabs Apr 3, 2026
@jaidhyani jaidhyani force-pushed the fix/tolerant-page-enumeration branch from b52c9b1 to ed654ad Compare April 3, 2026 04:29
… many tabs

When connecting to a running browser via --browserUrl, browser.pages()
hangs indefinitely if any tab is unresponsive (discarded by memory
management, dead localhost, etc). This blocks all tool calls since page
enumeration runs on every request.

Add a new --skipUnresponsiveTabs CLI flag (default: false). When enabled:

1. Sets protocolTimeout (15s) on puppeteer.connect() so CDP commands
   fail with an error instead of hanging forever.

2. Wraps browser.pages() in #getAllPages() with a 10s timeout. If it
   fails, falls back to per-target enumeration: iterates
   browser.targets(), calls target.page() on each with a 5s timeout,
   and skips tabs that don't respond.

When the flag is off, behavior is identical to before.

Tested with Chrome/Brave 145, 28 open tabs (5 discarded). Without this
flag the server hangs forever on the first tool call. With the flag it
returns 23 responsive pages in ~12s and logs the 5 it skipped.

Related: puppeteer/puppeteer#5633, puppeteer/puppeteer#14708, ChromeDevTools#870, ChromeDevTools#978
@jaidhyani jaidhyani force-pushed the fix/tolerant-page-enumeration branch from ed654ad to e611c86 Compare April 3, 2026 04:40
@jaidhyani jaidhyani marked this pull request as ready for review April 3, 2026 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant