Repository navigation
Close a wait whose own hook WebdriverIO skipped when its test ends - #532
Open
vishnuv688 wants to merge 3 commits into
Open
vishnuv688 wants to merge 3 commits into
vishnuv688 wants to merge 3 commits into
Conversation
WebdriverIO skips every command hook while another one is running. A wait times out from its own timer, so a timeout landing while a poll's afterCommand is still taking its screenshot made WDIO skip the wait's afterCommand: the wait kept its running row with no error, and the poll hook, outliving its test, swallowed the next test's first command. The conformance scenario failed this way 28 of 60 times with the fake driver's screenshot delayed. At the end of each test, step or scenario the service now waits for its own command hooks to settle (under a 10 s ceiling, paid once) and closes every wait still open, innermost first, with the test's outcome, before the outcome marks a row and before the per-test slice is flushed. Closes #529 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Core logs the trace path at info level, which the usual logLevel: 'warn' hides, so a trace-mode run ended without saying where its trace went. The service now writes each kept trace's path to stdout once capture is torn down, so the line never lands in a trace's own console and shows whatever the log level. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ait-flake # Conflicts: # packages/service/src/index.ts
This branch has not been deployed
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.
What & why
Closes #529. Part of #494.
The conformance suite failed now and then on the WDIO "times out waiting for a missing element" test. The cause is a real service bug, not a test problem.
WebdriverIO keeps one module-global flag and skips every command hook that starts while another hook is running. A wait times out from its own timer, whatever its poll is doing. When that timeout landed while a poll's
afterCommandwas still awaiting its screenshot and drain, WDIO skipped the wait's ownafterCommand:With the fake driver's screenshot delayed 0-150 ms, the conformance scenario failed 28 of 60 runs on main and 0 of 60 with this change.
The fix: at the end of each test, step or scenario (
afterTest,afterStep,afterScenario), the service:This runs before the outcome marks a row and before the per-test trace slice is written, so the trace carries the closed wait.
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 user-facing feature changes; a wait row now shows the failure it already had.
Notes for reviewers
Why only the service: the shared hook flag is WebdriverIO's; the other adapters capture waits through their own patches and never lose a wait's outcome this way.
What the service observes:
HooksInFlightreturns the hook promise it tracks unchanged, so WDIO awaits exactly what it awaited before. CLAUDE.md treats that hook timing as load-bearing.The error on a closed wait goes through the service's existing failure normalizer (
toCommandError): ANSI stripped, a Cucumber string error kept as the runner reported it, and an assertion failure left on its own row rather than shown twice.An earlier approach was dropped: deferring the poll's capture until after the wait. It risked a screenshot landing mid-click, and other services' hooks could reintroduce the bug.
Residuals (in the CLAUDE.md entry):
before/afterhooks, or in runs with no per-test hooks, are not closed.Review: an independent review found nothing blocking. It raised the error normalization, the repeated ceiling and the residuals above, all now addressed; each new test was confirmed to fail without its fix.
Testing
pnpm build,pnpm lintand the leak grep are green.pnpm testpassed in full (3539 passed, 1 skipped). Other full runs on a heavily loaded machine hit timing flakes in files this PR does not touch (a Selenium conformance scenario timeout, Nightwatch attempt tracking, service session tests); each passed when rerun alone.packages/service/tests/wait-rows.test.tsmodel WDIO's hook flag and cover: element and top-level waits, nested waits, a passed test, Cucumber steps, the next test's first command, the error shape, and the ceiling.Also in this PR: the trace path is printed. Core logs "Trace saved to" at
info, which the usual WDIOlogLevel: 'warn'hides, so a trace-mode run never said where its trace went. Once capture is torn down inafter(), the service writes each kept trace's path to stdout (DevTools trace saved to <path>), whatever the log level. Writing it any earlier would put the line in the trace's own Console tab. The README notes it for the WebdriverIO service only: Selenium, Nightwatch and Python still log the path atinfo. Not yet checked: a config that setsoutputDir, where WDIO sends logger output to files.Needs checking by hand:
pnpm demo:wdio:mochalive, then in trace mode (DEVTOOLS_MODE=trace). Check that wait rows still nest their polls and close when they finish, and that a failing wait shows its timeout. In trace mode, the trace path prints at the end of the run.🤖 Generated with Claude Code