Skip to content

feat: print partial report and exit 130 on SIGINT - #25

Merged
paveg merged 1 commit into
mainfrom
feat/sigint-partial-report
Jul 18, 2026
Merged

paveg merged 1 commit into
mainfrom
feat/sigint-partial-report

Conversation

@paveg

@paveg paveg commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

When a load test is interrupted with Ctrl-C (SIGINT),
molt now prints the statistics collected so far and exits with code 130 (128 + SIGINT),
instead of dying without a report.

Since async 0.18, SIGINT/SIGTERM cancel the whole async program gracefully by default.
Previously that cancellation propagated straight out of coordinator.run()'s task group and killed the process reportless.

Changes

  • coordinator.run() catches cancellation (via the public @async.is_cancellation_error predicate; any other task-group failure still propagates) and falls through to the existing finalize/report path, so partial stats are collected and printed. TUI terminal restore (on_cleanup) runs before the report, unchanged
  • run() now returns RunOutcome { stats, interrupted } instead of bare Stats, keeping the interrupted state explicit without touching the shared Stats type
  • main exits 130 when interrupted; this takes precedence over threshold (3) and failed-request (2) exit codes.
    Both signal-triggered and externally-induced cancellation flow through the same Cancelled error in the async runtime (verified in the moonbitlang/async source), so one mechanism covers both
  • Also removes an unreachable panic() after @sys.exit(3) in the threshold path

Verification

  • TDD: the new integration test (cancel coordinator.run mid-flight, assert partial stats are returned with interrupted=true) was confirmed failing to compile before the implementation existed
  • moon test --target native 272/272, moon test (wasm-gc) 195/195, after rebasing onto current main
  • End-to-end with the release binary: SIGINT sent 2s into a 30s run → full summary printed (55k requests collected) and exit code 130; an uninterrupted run still completes normally with exit 0

Known minor behavior: requests in flight at the moment of cancellation are recorded as Other(Cancelled) errors in the report (2 occurrences in the E2E run above). Left as-is in this PR to keep the change minimal.

🤖 Generated with Claude Code

async 0.18+ cancels the whole program on SIGINT/SIGTERM by default via
moonbitlang/async/signal, which previously propagated straight out of
coordinator.run()'s task group and killed the process before any stats
were reported. Catch only @async.is_cancellation_error and fall through
to the existing finalize/report path so partial stats are still
collected and printed, then exit 130 (128 + SIGINT) once main has
finished reporting.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jul 18, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 478f40a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.73%. Comparing base (f869166) to head (478f40a).

Files with missing lines Patch % Lines
src/cmd/main/main.mbt 0.00% 2 Missing ⚠️
src/lib/coordinator/coordinator.mbt 66.66% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #25      +/-   ##
==========================================
+ Coverage   70.81%   71.73%   +0.91%     
==========================================
  Files          16       16              
  Lines         747      750       +3     
==========================================
+ Hits          529      538       +9     
+ Misses        218      212       -6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@paveg
paveg merged commit 8b98e38 into main Jul 18, 2026
4 checks passed
@paveg
paveg deleted the feat/sigint-partial-report branch July 18, 2026 21:53
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.

2 participants