Skip to content

fix: Isolate cleanup steps in Actor __aexit__ to prevent cascading failures#842

Merged
vdusek merged 2 commits intomasterfrom
fix/actor-aexit-cleanup-resilience
Mar 27, 2026
Merged

fix: Isolate cleanup steps in Actor __aexit__ to prevent cascading failures#842
vdusek merged 2 commits intomasterfrom
fix/actor-aexit-cleanup-resilience

Conversation

@vdusek
Copy link
Copy Markdown
Contributor

@vdusek vdusek commented Mar 26, 2026

Summary

  • Wrap each cleanup step in finalize() (event_manager.__aexit__, _charging_manager_implementation.__aexit__, _save_actor_state) with independent try/except blocks
  • Previously, if event_manager.__aexit__() raised, charging manager exit and state persistence were skipped entirely
  • Failures are now logged and don't prevent subsequent cleanup steps from executing

Test plan

  • Existing unit tests pass (182/182)
  • Verify cleanup resilience by injecting a failure in one cleanup step and confirming others still run

🤖 Generated with Claude Code

…failures

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@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 Mar 26, 2026
@vdusek vdusek self-assigned this Mar 26, 2026
@vdusek vdusek requested a review from Pijukatel March 26, 2026 16:11
@github-actions github-actions bot added this to the 137th sprint - Tooling team milestone Mar 26, 2026
@vdusek vdusek removed the request for review from Pijukatel March 26, 2026 16:14
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.31%. Comparing base (1610d0d) to head (34d3836).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
src/apify/_actor.py 50.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #842      +/-   ##
==========================================
- Coverage   86.40%   86.31%   -0.10%     
==========================================
  Files          48       48              
  Lines        2906     2915       +9     
==========================================
+ Hits         2511     2516       +5     
- Misses        395      399       +4     
Flag Coverage Δ
e2e 37.94% <0.00%> (-0.12%) ⬇️
integration 59.38% <50.00%> (-0.09%) ⬇️
unit 74.33% <50.00%> (-0.06%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 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 marked this pull request as draft March 26, 2026 16:14
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vdusek vdusek marked this pull request as ready for review March 26, 2026 16:19
@vdusek vdusek requested a review from Pijukatel March 26, 2026 16:19
@vdusek vdusek merged commit 68c2acf into master Mar 27, 2026
31 checks passed
@vdusek vdusek deleted the fix/actor-aexit-cleanup-resilience branch March 27, 2026 11:21
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants