Skip to content

Conversation

barjin
Copy link
Contributor

@barjin barjin commented Jul 30, 2025

Encountered in https://console.apify.com/view/runs/ZlPUJOjFTsIHzH8dP

image

WARN Main crawler finished successfully, exiting the run... is the last log line before the Actor.exit() call. The internals of the call seem to be blocking execution for ~1 hour, before the Platform migrates.

These changes place the process.exit() call into the event loop before any potentially time-consuming operations.

@barjin barjin requested a review from Copilot July 30, 2025 12:06
@barjin barjin self-assigned this Jul 30, 2025
@barjin barjin added the adhoc Ad-hoc unplanned task added during the sprint. label Jul 30, 2025
@github-actions github-actions bot added this to the 120th sprint - Tooling team milestone Jul 30, 2025
@github-actions github-actions bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Jul 30, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where Actor.exit() calls could get stuck for extended periods (up to an hour) before the platform migration occurs. The fix adds a hard timeout mechanism to ensure the process exits within the specified timeout period.

  • Adds a setTimeout that forces process.exit() after the timeout period
  • Ensures the timeout only applies when options.exit is true
  • Places the forced exit in the event loop before potentially time-consuming operations

@barjin barjin requested a review from janbuchar July 30, 2025 12:12
);

if (options.exit) {
// `addTimeoutToPromise` is a cooperative timeout. This ensures that the process exits
Copy link
Contributor

Choose a reason for hiding this comment

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

Well, if something hogs the event loop with something CPU-intensive, the setTimeout won't fire, but this surely is better than the previous state

@barjin barjin merged commit 483fc43 into master Jul 30, 2025
9 checks passed
@barjin barjin deleted the fix/unblock-stuck-exit-calls branch July 30, 2025 14:22
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.

2 participants