feat: add --skipUnresponsiveTabs flag for connecting to browsers with many tabs#1804
Open
jaidhyani wants to merge 1 commit intoChromeDevTools:mainfrom
Open
feat: add --skipUnresponsiveTabs flag for connecting to browsers with many tabs#1804jaidhyani wants to merge 1 commit intoChromeDevTools:mainfrom
jaidhyani wants to merge 1 commit intoChromeDevTools:mainfrom
Conversation
|
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. |
2f32f29 to
c29e1e6
Compare
b52c9b1 to
ed654ad
Compare
… 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
ed654ad to
e611c86
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 noprotocolTimeout, andbrowser.pages()tries to attach to every target. One bad tab blocks everything.This adds
--skipUnresponsiveTabs(default: false). When on:protocolTimeout: 15son connectbrowser.pages()times out (10s), falls back to per-target enumeration with 5s individual timeoutsFlag 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