Skip to content

fix(rerun): emit partial stdout on TimeoutError in single-FE rerun --wait#155

Open
Awad-de wants to merge 3 commits into
TestSprite:mainfrom
Awad-de:fix/pr134-clean
Open

fix(rerun): emit partial stdout on TimeoutError in single-FE rerun --wait#155
Awad-de wants to merge 3 commits into
TestSprite:mainfrom
Awad-de:fix/pr134-clean

Conversation

@Awad-de

@Awad-de Awad-de commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes an asymmetry in testsprite test rerun --wait (single FE rerun path):
when the overall --timeout polling deadline is exceeded, the CLI now emits a
partial { runId, status: "running" } object to stdout before throwing
exit 7 — matching the behavior already present for RequestTimeoutError and
the recently fixed test run --wait / test wait paths.

Before: TimeoutError → throw ApiError immediately → stdout empty in
--output json mode → AI agents must scrape stderr to recover the runId.

After: TimeoutErrorout.print({ runId, status: "running" }) → throw
→ caller can programmatically chain into testsprite test wait <runId>.

Related issue

Fixes #157

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that changes existing behavior)
  • Documentation only
  • Build / CI / chore

Checklist

  • PR targets the main branch.
  • Commits follow Conventional Commits
    (feat(...), fix(...), docs(...), …).
  • npm run lint and npm run format:check pass.
  • npm run typecheck passes.
  • npm test passes and coverage stays at or above the 80% gate.
  • New behavior is covered by unit tests (mock-based; no network or
    credentials required).
  • No secrets, API keys, internal endpoints, or personal data are included.
  • User-facing changes are reflected in README.md / DOCUMENTATION.md where
    relevant. (N/A — internal error-handling parity fix, no CLI surface change.)

Notes for reviewers

Root cause

In runTestRerun (single FE rerun, no BE closure), the TimeoutError catch
block at ~line 6132 called ticker.finalize() then threw ApiError without
any out.print(). The adjacent RequestTimeoutError branch already emitted
a partial run to stdout — this was simply a missed mirror.

Scope

  • Changed: single-FE test rerun --wait TimeoutError path only (~12 lines).
  • Not changed: BE closure fan-out paths — those already aggregate runIds
    into the batch result object on timeout; test run --wait / test wait
    were fixed in a prior PR.

Test added

[finding-4] in test.rerun.spec.ts:

  • triggers TimeoutError via timeoutSeconds: 0 (immediate deadline)
  • asserts exit code 7
  • asserts stdout contains parseable JSON { runId, status: "running" }

Verification

npm test        → 1571 passed
npm run typecheck → clean
npm run lint:fix  → clean

Summary by CodeRabbit

  • Bug Fixes
    • Improved test rerun behavior for --wait timeouts by emitting a partial run update to standard output before the failure is returned.
    • The output now includes the rerun runId and status: running, making it easier to capture progress while a rerun is still in progress.
    • Text output adds an actionable reattach hint so you can continue monitoring the in-progress rerun after a timeout.

…wait

Apply the fix in src/commands/test.ts. When the overall --timeout polling
deadline is exceeded on a single FE rerun, emit {runId, status:"running"}
to stdout before exit 7.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a1a6cd31-8958-42c7-a960-14b8de3ae3ce

📥 Commits

Reviewing files that changed from the base of the PR and between 0530b28 and 1752b87.

📒 Files selected for processing (1)
  • src/commands/test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/commands/test.ts

Walkthrough

Adds partial JSON stdout output when a single FE rerun with --wait times out, emitting { runId, status: 'running' } plus a reattach hint before throwing the timeout error, and adds a test verifying this behavior and the exit code.

Changes

Rerun timeout partial output

Layer / File(s) Summary
TimeoutError partial stdout payload and test coverage
src/commands/test.ts, src/commands/test.rerun.spec.ts
On TimeoutError during single FE rerun --wait polling, prints a partial { runId, status: 'running' } payload with reattach hint to stdout before throwing the timeout ApiError; new test mocks rerun and polling to assert exit code 7 and correct partial JSON output.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers: ruili-testsprite, zeshi-du

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: emitting partial stdout on TimeoutError in single-FE rerun --wait.
Linked Issues check ✅ Passed The code and test changes implement the requested partial JSON stdout on TimeoutError for single-FE rerun --wait.
Out of Scope Changes check ✅ Passed The diff appears limited to the timeout stdout fix and its test coverage, with no unrelated changes evident.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@Awad-de

Awad-de commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

Discord:
Username = muathawad_37013
ID = Muath Awad

@zeshi-du

zeshi-du commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Approved — this redo is exactly what we asked for: only the claimed fix, mirroring the existing RequestTimeoutError partial-stdout contract. Its sibling (#153) merged today, which is also what made this one go CONFLICTING (same regions of test.ts). One more rebase onto current main and it merges — thanks for sticking with the redo process.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/commands/test.ts (1)

6638-6684: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

Consider consolidating the repeated timeout-partial-print pattern.

The { runId, status: 'running' as const } + out.print(..., renderer) + reattach-hint block is now duplicated 6 times across runTestRun, runTestWait, and runTestRerun (this PR adds the 6th instance). A small shared helper (e.g. printTimeoutPartial(out, { runId, extra?, timeoutSeconds, reason })) would reduce drift risk across these near-identical call sites, though the per-site field differences (enqueuedAt/codeVersion/targetUrl in runTestRun vs bare runId/status here) mean some parameterization is needed.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commands/test.ts` around lines 6638 - 6684, The timeout-partial rendering
logic is duplicated again in the error handling around the rerun polling path,
so factor the repeated `{ runId, status: 'running' as const }` plus
`out.print(..., renderer)` and reattach-hint behavior into a shared helper.
Update the catch block in `runTestRerun` to call that helper, and design it so
existing call sites in `runTestRun` and `runTestWait` can share it while still
allowing their extra fields and message variations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/commands/test.ts`:
- Around line 6638-6684: The timeout-partial rendering logic is duplicated again
in the error handling around the rerun polling path, so factor the repeated `{
runId, status: 'running' as const }` plus `out.print(..., renderer)` and
reattach-hint behavior into a shared helper. Update the catch block in
`runTestRerun` to call that helper, and design it so existing call sites in
`runTestRun` and `runTestWait` can share it while still allowing their extra
fields and message variations.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b7883e5f-dbf7-41f8-8ed5-4bc9148977db

📥 Commits

Reviewing files that changed from the base of the PR and between cff19ae and 0530b28.

📒 Files selected for processing (2)
  • src/commands/test.rerun.spec.ts
  • src/commands/test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/commands/test.rerun.spec.ts

@zeshi-du

zeshi-du commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Approved on content — #154 landed just ahead of this and took the adjacent test.ts region with it, so this now shows conflicting. Rebase on latest main and it merges on green (no re-review needed unless the resolution changes behavior).

@Awad-de

Awad-de commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@zeshi-du Hii Thank you, and sorry for the inconvenience. Everything should be ready.

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.

[Hackathon] fix(rerun): partial stdout on TimeoutError in single-FE rerun --wait (#155)

2 participants