Repository navigation
fix(cli): TestHub acts on the dispatched test state, not the shared one (v9) - #413
AakashHotchandani wants to merge 3 commits into
Conversation
TestHub read the instance's current state when its observer ran. Observers run one after another, so when an earlier TEST/POST observer awaits (the Automate session rename after a mid-test reloadSession), console output from the user's afterTest lands as LOG/POST in the meantime and overwrites that state. TestHub then handled the TEST/POST as a log, never queued the finish, and the test was left open until Test Hub timed it out (finished_at NULL). Pass the dispatched state to onAllTestEvents and use it, including for the immediate send. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 16b5606)
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
✅ Good to go — no blocking findings. Reviewed at
Verified
💡 Follow-ups (non-blocking, outside this diff)
Change mapgraph LR
subgraph nwdio_service["wdio-service"]
n1["⚠ testHubModule.deferredFinish.test.ts<br/>~75 lines"]
n2["testHubModule.ts<br/>~11 lines"]
n3["testHubModule.test.ts<br/>~11 lines"]
n4["pr-413.md<br/>~5 lines"]
end
↻ This verdict comment is the review anchor — it's updated in place on each run (the gate posts its status separately). — SDK PR Review Agent |
|
🟢 SDK PR Review gate is green — the SDK PR Review Agent has run on the current head commit (verdict: This gate confirms a review ran on the latest commit. The verdict itself is advisory — read the findings and use your judgement; it does not block merge. A native GitHub reviewer approval is still separately required by branch protection before this PR can merge. |
|
RUN_TESTS |
|
[SDK Wdio Test] TRA build state: passed | Stability 100% — verdict: success. Passed: 58, Failed: 0, Aggregate: 58. TRA: https://observability.browserstack.com/builds/gqah1hflt9snyy1dl4mg9w3i8dq1xjlmwgm8uqyv |
What is this about?
v9 port of #412. The v9 CLI flow has the same race. A mocha test that calls
browser.reloadSession()mid-test, with a configafterTestthat writes to the console, never gets itsTestRunFinished. Test Hub then times the test out (status=timeout,finished_atNULL), which TRA counts undermetadata_issue_non_timeout(n_missing_timestamps).Cause (same as #412,
cli/modules/testHubModule.ts):onAllTestEventsreads the instance's shared current state, not the state it was dispatched for.AutomateModule.onAfterTestawaits the session rename before TestHub's observer runs.afterTestlands as LOG/POST during that wait and overwrites the state.Change: cherry-pick of #412 (
git cherry-pick -x). It applied cleanly.(state, hook)toonAllTestEvents, which uses them.sendTestFrameworkEventpasses the dispatched state asstateOverride.Checks (local, Node 26):
vitest run tests/cli: 506 passed, 4 failed. The same 4cliUtilsnetwork tests also fail onmain.testHubModule.tsreverted (1 failed, 14 passed).eslinton the changed files: clean.main(v10)node_modules. With those deps,tsc -p tsconfig.prod.jsonreports 78 errors on this branch both with and without the change, none intestHubModule.ts. A typecheck with v9 deps is left to CI.scripts/build.mjs) builds.End to end (Automate, Windows 11 + Chrome):
@wdio/cli/mocha-framework/webdriverio9.33.1, with@wdio/browserstack-service9.44.4 installed. The npm guard here would not install 9.44.5 yet.build/index.js+cleanup.jswere replaced with bundles built from this branch (origin/v99.44.5, with and without the fix).reloadSession(). The configafterTestlogs, sleeps 150 ms, then logs again.TestRunFinishedreceived by the binaryBQ_METRIC_TRACKER)tyxh38jehsfczdqpmuh54vgmhua3eolmhujka0glpassed: 3fiwymnknixzacxld5yf8immv5hkvfz97qtydfttcorigin/v9without the fixpassed: 34ubygf0eecelen8fmvpwiyqmii1hhmirdxz2b3b6passed: 4j9ya5khqyks17fyhbtyxd86itusdklzobr3b65paNot verified:
TestRunStarted.Related Jira task/s
metadata_issue_non_timeout)Release (mandatory for every PR — required for the
ready-for-reviewlabel)Version bump: (required — tick exactly one)
Release notes type: (optional)
Release notes (customer-facing): (optional but encouraged)
afterTesthook writes console output.Release notes (internal): (required — engineer-facing; what actually changed / why)
Checklist
PR Validations
Run Tests: Comment RUN_TESTS to trigger sanity tests.
🤖 Generated with Claude Code