Skip to content

feat(cli): fail fast when async test-session dispatch fails [RED-680]#1420

Open
sorccu wants to merge 1 commit into
mainfrom
simo/red-680-fail-fast-on-scheduling-failure
Open

feat(cli): fail fast when async test-session dispatch fails [RED-680]#1420
sorccu wants to merge 1 commit into
mainfrom
simo/red-680-fail-fast-on-scheduling-failure

Conversation

@sorccu

@sorccu sorccu commented Jul 24, 2026

Copy link
Copy Markdown
Member

Linear: RED-680

What

checkly test currently streams results over MQTT and has no way to learn that the backend failed to dispatch the checks — a background scheduling failure leaves the CLI hanging until its own timeout. This PR makes the CLI fail fast:

  • TestSessions.run() now calls POST /v1/test-sessions/run, whose 202 includes a schedulingId backed by a scheduling-operation status row.
  • While results stream, a watchScheduling promise polls GET /v1/test-sessions/scheduling/{schedulingId}/completion (30s long-poll, 408 → retry) and rejects with TestSessionSchedulingFailedError (code: SCHEDULING_ERROR | ABANDONED) the moment dispatch fails — including when the scheduling worker dies and the backend reaper reclaims the operation.
  • --detach awaits scheduling success before emitting DETACH, so a dispatch failure is no longer silently swallowed in detach mode.
  • Poll infrastructure errors are best-effort: they never fail an otherwise healthy run.

Behavior notes (accepted)

  • An ERROR can now surface mid-stream (previously only at start or timeout).
  • --detach gains a few seconds of latency (one completion poll round-trip).
  • The 408 retry loop is deliberately unbackoffed, matching the deploy completion polling convention.

Backend dependency

Requires the v1 test-session scheduling endpoints from checkly/monorepo#2795 (in the merge queue at the time of writing). Blocked from release — not from merge — until that backend change is live in production: the CLI calls v1 unconditionally, with no fallback to the legacy endpoint (deliberate decision). Merging is safe; releasing before the backend is deployed would break checkly test for everyone on the new version.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HFcrNm7uzzkD1p87Nf9AhP

checkly test now runs sessions via POST /v1/test-sessions/run, which
dispatches the check runs in the background after the 202. The CLI watches
the returned scheduling operation (long-poll with 408 retries, aborted once
the run settles) and fails the run immediately with the server's error when
dispatch fails — previously a server-side dispatch failure produced no MQTT
results and the CLI hung for the full per-check timeout (600s, or 1200s for
Playwright) before printing a generic timeout.

In --detach mode the CLI confirms dispatch reached a terminal state before
detaching, so a dispatch failure still exits non-zero like the synchronous
endpoint did.

Requires the backend scheduling endpoints (checkly/monorepo#2795) — do not
release before they are live in production.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HFcrNm7uzzkD1p87Nf9AhP
@sorccu sorccu changed the title [RED-680] fix(backend): async test-session scheduling — /next/test-sessions/run 504 for 1200+ checks (+ POST /v1/test-sessions/run with completion polling) feat(cli): fail fast when async test-session dispatch fails [RED-680] Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant