Commit 2f32f29
fix: tolerate unresponsive tabs when connecting to existing browser
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.
Two changes:
1. Add protocolTimeout (15s) to puppeteer.connect() so CDP commands
fail with an error instead of hanging forever.
2. Wrap browser.pages() in #getAllPages() with a 10s timeout. If it
fails, fall back to per-target enumeration: iterate browser.targets(),
call target.page() on each with a 5s timeout, and skip tabs that
don't respond. This way one unresponsive tab doesn't block the
entire server.
Tested with Chrome/Brave 145, 28 open tabs (5 discarded). Without this
fix the server hangs forever on the first tool call. With the fix it
returns 23 responsive pages in ~12s and logs the 5 it skipped.
Related: puppeteer/puppeteer#5633, puppeteer/puppeteer#14708, #870, #9781 parent 9236834 commit 2f32f29
2 files changed
Lines changed: 42 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
562 | 562 | | |
563 | 563 | | |
564 | 564 | | |
565 | | - | |
566 | | - | |
567 | | - | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
568 | 606 | | |
569 | 607 | | |
570 | 608 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
0 commit comments