Fix detached test session output#1338
Conversation
|
AI-RV agent review summary @thebiglabasky I reviewed the detach scheduling path, reporter output changes, frequency-like value normalization, and the related unit coverage. Verdict: approve from code-review standpoint, but GitHub will not allow this account to submit an approving review on its own PR. I did not find any defect-grade issues. Verification:
|
a4609e8 to
905fee3
Compare
martzoukos
left a comment
There was a problem hiding this comment.
This is a great AX upgrade 👌 .
One small bug that Claude surfaced in which the cli drops a couple of output options with detach:
--detach silently skips onEnd(), so --reporter json and --reporter github write no report file
What happens
In AbstractCheckRunner.run(), the new detach branch schedules the checks, emits RUN_STARTED + DETACH, and returns early — before this.emit(Events.RUN_FINISHED, …). RUN_FINISHED is the only event wired to reporter.onEnd() (test.ts:431, trigger.ts:199, pw-test.ts:387). So in detach mode onEnd() is never called for any reporter.
For two reporters, onEnd() is the only place output is produced:
reporters/json.ts:78-96— thewriteFileSyncofcheckly-json-report.jsonlives entirely inonEnd(). In detach mode the file is never written.reporters/github.tsonEnd()— same pattern; the GitHub markdown summary file is never written.
(list.ts and ci.ts are mostly fine because onDetach() prints a human summary, though they skip the _printTestSessionsUrl() short link — the new onBegin reference lines cover the ID for them.)
Why this is a regression, not just a detach quirk
On main, a --detach run that ran to completion did emit RUN_FINISHED (abstract-check-runner.ts:146) and therefore did call onEnd() and write the json/github file. Only the Ctrl+C path skipped it. After this branch, detach always skips onEnd(). So anyone using --detach --reporter json (or github) to produce a report file gets nothing now — and there's no error or warning, the file just silently doesn't appear.
This is reinforced by the updated investigate-test-sessions.md, which steers agents toward both --detach and --reporter json — the combination an agent is most likely to use is exactly the broken one.
Note: this is a code-traced finding (I can't run it against a live backend in review), but the chain is structural: onEnd() is json/github's only write path, and onEnd() is unreachable under detach.
Repro
checkly test --detach --record --reporter json
# expected (old): ./checkly-json-report.json written
# actual (this branch): no file, no warningSuggested fixes (pick one)
- Preferred: still call the end-of-run path in detach. Either emit
RUN_FINISHEDafterDETACH, or have the detach branch produce a report containing thetestSessionIdwith an empty/schedulingchecksarray — so json/github emit a valid file an agent can parse for the session ID. - Make json/github
onDetach()write their file (with the session ID and no results yet). - If "no file in detach" is acceptable, say so explicitly: emit a one-line warning when
--detachis combined with a file reporter, and document it. Silent is the only outcome to avoid.
So that's a good catch 🙏🏻 (and I have an idea about why my agent did this 😬) but I differ on the conclusion. |
905fee3 to
9afd5ea
Compare
Summary
--detachfortest,trigger, andpw-testreturn immediately after scheduling a recorded test session.test-sessions get <id> --watch, and the canonical app URL once, so agents and humans have actionable handles without waiting for result streaming.--detachwith file reporters (json,github) because detached runs exit before result reports can be written.--detachfor agent workflows and usetest-sessions get --output jsonfor machine-readable follow-up.Frequencyobjects when the config and CLI load separate module instances.Validation
pnpm --filter checkly exec vitest --run ./src/helpers/__tests__/test-helper.spec.ts ./src/services/__tests__/abstract-check-runner.spec.ts ./src/reporters/__tests__/abstract-list.spec.ts ./src/commands/__tests__/command-metadata.spec.tspnpm --filter checkly exec vitest --run ./src/services/__tests__/abstract-check-runner.spec.ts ./src/reporters/__tests__/abstract-list.spec.ts ./src/constructs/__tests__/check.spec.ts ./src/commands/__tests__/command-metadata.spec.ts ./src/reporters/__tests__/json-builder.spec.ts ./src/reporters/__tests__/github-md-builder.spec.tspnpm --filter checkly run prepare:distpnpm --filter checkly run prepare:ai-contextpnpm --filter checkly run prepackCHECKLY_SKIP_AUTH=1 packages/cli/bin/run skills investigate test-sessionsCHECKLY_SKIP_AUTH=1 packages/cli/bin/run test --helpCHECKLY_SKIP_AUTH=1 packages/cli/bin/run trigger --detach --reporter jsonexits with a clear unsupported-reporter errorgit diff --check