Skip to content

fix!: honor explicit exit codes and control-flow signals in Actor exit#1048

Merged
vdusek merged 2 commits into
masterfrom
worktree-fix-b12
Jul 15, 2026
Merged

fix!: honor explicit exit codes and control-flow signals in Actor exit#1048
vdusek merged 2 commits into
masterfrom
worktree-fix-b12

Conversation

@vdusek

@vdusek vdusek commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Previously Actor.__aexit__ treated any BaseException as "the user function threw": it logged "Actor failed with an exception" and forced the exit code to 91 (EXIT_CODE_ERROR_USER_FUNCTION_THREW), ignoring any explicitly-requested exit code and mishandling control-flow signals.

Consequences:

  • Actor.fail(exit_code=42, exception=e) silently exited 91, contradicting the fail() docstring and the error-handling guide example (which maps ValueError10).
  • sys.exit(5) inside the Actor block exited 91 instead of 5.
  • KeyboardInterrupt (Ctrl+C) became a logged failure + exit 91 instead of interrupt semantics.
  • asyncio.CancelledError was consumed by sys.exit(91), breaking the cancellation contract.

Now __aexit__ dispatches on the exception type:

  • a regular Exception still falls back to 91, but only when no exit code was set explicitly (so fail(exit_code=X, exception=e) honors X);
  • SystemExit keeps its own code;
  • every other BaseException (Ctrl+C, task cancellation, ...) is re-raised untouched after cleanup.

Added regression tests covering all four cases.

BREAKING CHANGE: Actor exit codes and failure logging are now accurate to the exception type. fail(exception=e) exits with the requested exit_code (default 1) instead of always 91; sys.exit(n) inside the Actor block exits n instead of 91; KeyboardInterrupt and asyncio.CancelledError propagate instead of becoming a logged failure with exit 91; and "Actor failed with an exception" is no longer logged for those control-flow cases.

@vdusek vdusek added adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. labels Jul 15, 2026
@vdusek vdusek self-assigned this Jul 15, 2026
@github-actions github-actions Bot added this to the 145th sprint - Tooling team milestone Jul 15, 2026
@github-actions github-actions Bot added the tested Temporary label used only programatically for some analytics. label Jul 15, 2026
@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.71%. Comparing base (ed1d8eb) to head (7d38e9b).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1048      +/-   ##
==========================================
- Coverage   91.75%   91.71%   -0.05%     
==========================================
  Files          50       50              
  Lines        3215     3222       +7     
==========================================
+ Hits         2950     2955       +5     
- Misses        265      267       +2     
Flag Coverage Δ
e2e 35.56% <0.00%> (-0.08%) ⬇️
integration 57.35% <44.44%> (-0.04%) ⬇️
unit 83.05% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vdusek vdusek requested a review from Pijukatel July 15, 2026 13:12
@vdusek vdusek marked this pull request as ready for review July 15, 2026 13:12
@vdusek vdusek requested a review from szaganek as a code owner July 15, 2026 13:12
@vdusek vdusek merged commit 573e3a3 into master Jul 15, 2026
57 of 59 checks passed
@vdusek vdusek deleted the worktree-fix-b12 branch July 15, 2026 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants