Skip to content

Time out capture calls on Chrome 156/157 so a popup tab cannot hang a test - #588

Merged
vishnuv688 merged 3 commits into
mainfrom
fix/574-chrome-popup-bidi-ceilings
Nov 25, 2026
Merged

vishnuv688 merged 3 commits into
mainfrom
fix/574-chrome-popup-bidi-ceilings

Conversation

@vishnuv688

@vishnuv688 vishnuv688 commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

What & why

Closes #574.

Chrome 156 and 157 never answer a WebDriver BiDi command for a tab opened by window.open() (crbug 571161446, fixed in 158.0.8106.0; WebdriverIO pinned its own CI to Chrome 155 for it in webdriverio/webdriverio#16206). Chrome 157 is current stable. A DevTools capture call aimed at such a tab waited forever, and with it the user's test.

On Chrome 156 and 157 only, outside Appium, capture calls now have ceilings:

Call Ceiling On timeout
BiDi preload registration, console and network subscriptions 10 s session falls back to per-document injection and the page's own console/network; a registration that answers later is removed or inert
Collector drain or injection (WDIO, Selenium) 5 s skipped; a cut-off drain returns a sentinel so it does not set off a collector re-injection
Screenshot, url or performance read (WDIO, Selenium) 4 s skipped

The first timeout in a session logs one warning naming the bug and the fixed version. Capture keeps trying, so while the test sits on a hung popup each capture call aimed at it pays its ceiling. Selenium's navigation injection stops at its first cut-off call, so a hung tab costs one ceiling per navigation rather than about 41 s.

Every other browser, and every Appium session, waits on capture exactly as before.

Type of change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Polish (an improvement to an existing feature)
  • Breaking change (existing behavior changes for users)
  • Documentation
  • Internal (build, CI, dependencies, tooling)

Packages touched

  • shared (types and contracts)
  • core (framework-agnostic capture/reporting)
  • elements (published element/snapshot API — @wdio/elements)
  • service (WebdriverIO adapter)
  • nightwatch-devtools (Nightwatch adapter)
  • selenium-devtools (Selenium adapter)
  • selenium-devtools-py (Selenium Python adapter)
  • backend (server)
  • app (UI)
  • script (page-injected runtime)
  • trace (Trace mode)

Capability matrix

  • packages/conformance/src/features.ts updated, and tables regenerated with pnpm docs:capabilities, if this adds or changes user-facing behaviour

No capability changes: this keeps existing capture from hanging. pnpm docs:capabilities --check passes.

Notes for reviewers

Verified on Chrome for Testing 157 with a spec that opens a window.open() tab on the-internet.herokuapp.com, switches to it and back, then logs in, under WebdriverIO and Selenium in trace mode: the run finishes, the session logs no more than one warning, and the rows after the switch back keep their screenshots. Nightwatch and Python share the same guard through core and mirror-vectors.json and are covered by unit tests only.

  • Why all four adapters: the ceiling, the version check and the timeout sentinel are in core (capture-call-guard.ts), with Python mirroring the version check through mirror-vectors.json (popupBidiHang). Each adapter only routes its own calls through the guard.
  • Design history: an earlier version remembered a hung tab and skipped later calls to it. Three review rounds each found a way for that to skip the healthy opener (a timeout charged to the window current when it fired, fire-and-forget probes outliving a switch, an unknown first window handle). It was removed: a timed-out call now affects only itself. The cost is a ceiling per capture call while on a hung popup.
  • Not covered: a ceiling ends our wait, not the driver's work, so a driver that serialises classic commands still holds the user's next command behind a hung call; the test's own commands to the popup can still hang on 156/157.
  • Checks: pnpm build, pnpm lint (0 errors), pnpm test (306 files, 4183 passed), pnpm docs:capabilities --check, the Python wire-type sync check, and the Python suite under CI's command (938 tests) are green; the bundle leak grep finds nothing.
  • The webdriver.io docs note ("popup flows need Chrome 155 or 158+") follows in webdriverio/webdriverio.

Screenshots / recordings

Not applicable: no UI change.

… test

Chrome 156 and 157 never answer a WebDriver BiDi command for a tab opened by
window.open() (crbug 571161446, fixed in 158.0.8106.0). A capture call aimed
at such a tab waited forever, and with it the user's test.

On those two versions only, outside Appium, capture calls now have ceilings:
BiDi setup (preload and console/network subscriptions) 10 s, a collector drain
or injection 5 s, a screenshot, url or performance read 4 s. A call that runs
out is skipped and the test carries on; setup falls back to per-document
injection, late registrations are made inert, and a cut-off drain does not set
off a collector re-injection. The first timeout in a session logs one warning
naming the bug. Every other browser waits on capture exactly as before.

Closes #574
@vishnuv688 vishnuv688 self-assigned this Nov 24, 2026
@vercel

vercel Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
devtools Ready Ready Preview Nov 25, 2026 3:03am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The latest test change appears safe to merge; the earlier non-blocking loss of events during successful BiDi setup remains.

Findings

  1. P2 Successful setup drops early events ▶

Summary

Adds capture time limits for desktop Chrome 156/157, with fallbacks and one warning per session.

  • BiDi setup stops waiting after ten seconds on affected Chrome sessions.
  • Capture reads stop waiting on hung Chrome popup calls.

Reviews (3) · Last reviewed commit: "Stub the collector bundle read in the Se..." · Reviewed by Greptile

Comment thread packages/core/src/bidi.ts
Comment on lines +453 to +460
const guarded: BidiHandlerSinks = {
pushConsoleLog: unlessAborted(signal, sinks.pushConsoleLog),
pushNetworkRequest: unlessAborted(signal, sinks.pushNetworkRequest),
replaceNetworkRequest: (id, entry) => {
if (!signal.aborted) {
sinks.replaceNetworkRequest(id, entry)
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Timeout leaves page capture disabled

On Chrome 156/157, an earlier listener can deliver events while a later subscription is still waiting. Those events set bidiNetworkObserved or bidiConsoleObserved. If setup then times out, these wrappers silence future events but leave those flags true. Selenium keeps dropping the page's matching stream, so later console messages or network requests disappear instead of falling back.

Restore the page stream when setup aborts, or wait until setup succeeds before publishing events. Python needs the same cleanup: stats["attached"] can stay true after cancellation because undo only runs when the abandoned worker finishes.

Knowledge Base Used: Core test observability

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in da3731f: BiDi listeners now stay inert until every subscription of their setup has answered within its ceiling, so an event delivered while a later subscription is still waiting sets no `bidiNetworkObserved` / `bidiConsoleObserved`, and a setup that times out leaves the page's own console and network as the capture. In Python, `network_serving` is false once the network subscription was abandoned at its ceiling, whatever it delivered before. Tests in `capture-call-guard.test.ts` and `test_bidi.py` fail without the fix.

An event delivered after one listener registered, while a later
subscription of the same setup was still waiting, set the session's BiDi
evidence (bidiNetworkObserved, bidiConsoleObserved). If that setup then ran
out its ceiling the listeners went quiet but the flags stayed set, so the
page's own console and network rows kept being dropped for the rest of the
session. Listeners now stay inert until every subscription of their setup has
answered in time. In Python, a network subscription abandoned at its ceiling
no longer counts as serving, whatever it delivered before.

Addresses review comments on #588
Comment thread packages/core/src/bidi.ts
handler: (event: E) => void
): (event: E) => void {
return (event) => {
if (gate.open && !signal.aborted) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Successful setup drops early events

whileServing discards events while gate.open is false, even when setup later succeeds. Nightwatch reconnects capture without waiting, so the page can emit console messages and finish requests during this gap. Opening the gate never publishes those events. Later BiDi events can also disable the page's Resource Timing fallback, leaving those completed requests missing.

Buffer events until setup succeeds, then publish them. Discard the buffer only when setup fails or times out.

Knowledge Base Used: Core test observability

The test drives injection on fake timers, but injection first reads the
collector bundle from disk, which fake timers cannot advance. On a slow CI
disk the test's timer steps ran out before the read returned, so the
injection never reached its polls and the test failed with done still false.
A stubbed read makes it independent of disk speed.
@vishnuv688
vishnuv688 merged commit 8924b0e into main Nov 25, 2026
17 checks passed
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.

Time out BiDi capture calls so Chrome 156/157 popup tabs cannot hang a test

1 participant