Repository navigation
Time out capture calls on Chrome 156/157 so a popup tab cannot hang a test - #588
Conversation
… 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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
[Medium impact] The latest test change appears safe to merge; the earlier non-blocking loss of events during successful BiDi setup remains. Findings
SummaryAdds capture time limits for desktop Chrome 156/157, with fallbacks and one warning per session.
Reviews (3) · Last reviewed commit: "Stub the collector bundle read in the Se..." · Reviewed by Greptile |
| const guarded: BidiHandlerSinks = { | ||
| pushConsoleLog: unlessAborted(signal, sinks.pushConsoleLog), | ||
| pushNetworkRequest: unlessAborted(signal, sinks.pushNetworkRequest), | ||
| replaceNetworkRequest: (id, entry) => { | ||
| if (!signal.aborted) { | ||
| sinks.replaceNetworkRequest(id, entry) | ||
| } | ||
| } |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
| handler: (event: E) => void | ||
| ): (event: E) => void { | ||
| return (event) => { | ||
| if (gate.open && !signal.aborted) { |
There was a problem hiding this comment.
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.
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:
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
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.tsupdated, and tables regenerated withpnpm docs:capabilities, if this adds or changes user-facing behaviourNo capability changes: this keeps existing capture from hanging.
pnpm docs:capabilities --checkpasses.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 throughcoreandmirror-vectors.jsonand are covered by unit tests only.core(capture-call-guard.ts), with Python mirroring the version check throughmirror-vectors.json(popupBidiHang). Each adapter only routes its own calls through the guard.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.Screenshots / recordings
Not applicable: no UI change.