Repository navigation
fix(cli): TestHub acts on the dispatched test state, not the shared one - #412
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>
|
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.
Verified
💡 Follow-up (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-412.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 |
|
RUN_TESTS |
|
🟢 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. |
|
[SDK Wdio Test] TRA build state: failed | Stability 79% — verdict: failure. Passed: 38, Failed: 10, Aggregate: 48. TRA: https://observability.browserstack.com/builds/hy1hwt7abenyam8poibs1xsfgrwdd3mvddvcpzk8 |
What is this about?
On the CLI flow, a mocha test that calls
browser.reloadSession()mid-test never gets itsTestRunFinishedwhen the user'safterTestwrites to the console. Test Hub later times the test out (status=timeout,finished_atNULL). TRA counts that undermetadata_issue_non_timeout(n_missing_timestamps). Seen in production on 10.0.0. 10.0.1 has the same code.Cause (
cli/modules/testHubModule.ts):onAllTestEventstakes the state frominstance.getCurrentTestState()/getCurrentHookState(). It doesn't use the event it was dispatched for.TestFramework.updateInstanceStateoverwrites it on everytrackEvent, LOG events included.notifyObserverruns the TEST/POST observers one at a time, and AutomateModule runs before TestHubModule.AutomateModule.onAfterTestawaitsmarkSessionName(about 350 ms), because the new session was never named.afterTest(which WDIO runs concurrently with the service's) logs. Each log becomes a LOG/POSTtrackEvent.service.after()then has nothing to flush.Probe log from a 10.0.0 repro (build
ni5sgzkn5ejnsviosnjchqjvh0n5dls5euzmqpnl):In the binary's end-of-run report, the reload test is
events=TestRunStarted complete=false,open=1. The other 3 tests read TEST/POST and were sent.Change:
(state, hook)toonAllTestEvents, which uses them. It falls back to the instance state when they're absent (direct callers).sendTestFrameworkEventpasses the dispatched state asstateOverride, so a non-deferred event can't be labelled with a later event's state.Checks (local, Node 26):
tsc -p tsconfig.prod.json --noEmitpasses;eslinton the changed files is clean.vitest run tests/cli: 505 passed, 4 failed. The same 4 fail on cleanmain(cliUtilsrequestToUpdateCLI×3 andcliUtils.staleBinary, which need the network).testHubModule.deferredFinish.test.ts:testHubModule.tsreverted, the first one fails.testHubModule.test.tswas updated for thestateOverrideargument.End to end (Automate, Windows 11 + Chrome; same spec: 2 control tests, 1 plain test, 1 test with a mid-test
reloadSession(); configafterTestlogs, sleeps 150 ms, logs again):Each build has 4 tests and 4
TestRunStarted. Columns:TestRunFinishedreceived by the binary (sdk-cli.log), and received by TestHub (observability_error_dataBQ_METRIC_TRACKERmetrics).qhgvsfqwxkttjmrygcyonxf8qaiuv3rmrgnfany6afterTestpassed: 47sbk5fbbfzjtuj7flyhepug43haplsjzkoumybegpassed: 3o3ggzublzuxfc1tt9r1sqetj6unwxubshcj3hbeopassed: 4em3zh1jup3kenykleyulyynjqlt77izyozv6cp3epassed: 4efxmkknq67s7hoqfxt1qvmn4ttkph2cefqnkfz8mpassed: 4On the unfixed runs, TestHub stored the reload test as
status=timeoutwithfinished_atNULL. That covers builds 180622794 (10.0.0), 180622797 (10.0.1) and 180626994 (the probe). The fixed builds' rows had not synced to BigQuery when this was written.Not verified:
v9has the same code. That port will come as a separate PR.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