Skip to content

Pay-per-event Actors sometimes end as FAILED after a successful run #1232

Description

@vdusek

Pay-per-event Actors running on the Apify platform sometimes end as FAILED even though they finished successfully. The Actor does all its work, logs Exiting Actor ({"exit_code": 0}), and then the process crashes with SIGABRT ("Aborted (core dumped)") while Python shuts down. The platform sees exit code 134 and marks the run as failed.

It happens in about 5% of runs on Python 3.11 to 3.13 and makes the charge E2E tests (tests/e2e/test_actor_charge.py) flaky:

The root cause is in impit: apify/impit#606. A Tokio thread that delivers the result of the last HTTP request can still be inside Python when the interpreter starts finalizing, and Python terminating that thread aborts the whole process.

#1222 made it show up. It stores the charging state in the key-value store during Actor.__aexit__, so the last impit request now finishes just milliseconds before sys.exit. Before #1222 we saw 0 crashes in 60 runs.

Closing the API clients at exit doesn't help, because impit has no real close. This needs a fix in impit. Until then, we can either accept the flaky charge E2E tests or find a way to move the final write away from process exit.

✍️ Drafted by Claude Code

Activity

  1. added
    t-toolingIssues with this label are in the ownership of the tooling team.
    on Nov 5, 2026
  2. added theissue type on Nov 5, 2026
  3. self-assigned this
    on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

t-toolingIssues with this label are in the ownership of the tooling team.

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions