Skip to content

fix: Report initial status and terminal status message (if saved)#780

Merged
jirispilka merged 7 commits intomasterfrom
fix/actor-run-abort-and-progress
May 5, 2026
Merged

fix: Report initial status and terminal status message (if saved)#780
jirispilka merged 7 commits intomasterfrom
fix/actor-run-abort-and-progress

Conversation

@jirispilka
Copy link
Copy Markdown
Collaborator

@jirispilka jirispilka commented May 1, 2026

Summary

Make actor-run progress and abort notifications reliable end-to-end.

  • Abort actually aborts. callActorGetDataset awaits the abort API call before returning on notifications/cancelled, so the run is aborted rather than fire-and-forget. The polling tracker is also stopped on the cancel path.
  • First progress arrives immediately. Initial actor-run status is reported before waitForFinish, so clients don't wait for the polling interval to see the first update.
  • Last progress is guaranteed and accurate. After waitForFinish resolves, the tracker is stopped and the run is re-fetched once (in parallel with dataset/build) to capture the actor's final statusMessage — the platform may write it just after the status flip. A terminal notification is then emitted explicitly so the client always sees SUCCEEDED/FAILED/etc., even if polling never ticked at terminal.
  • Status format is terminal-aware. formatRunStatusMessage always leads with the run status (apify/foo: SUCCEEDED — Done). At terminal status, the actor's statusMessage is only appended when explicitly marked terminal (isStatusMessageTerminal === true); otherwise it's omitted to avoid showing stale in-progress text.
  • No duplicate emissions. Three sources of duplicates closed:
    • Polling dedup state is seeded with the initial run, so the first poll tick doesn't re-emit the same state already sent at start.
    • A stopped flag in ProgressTracker prevents in-flight polling ticks from emitting after stop() is called.
    • updateProgress dedups consecutive identical messages, so a polling tick that catches the terminal state doesn't double up with the explicit final emit.
  • PROGRESS_NOTIFICATION_INTERVAL_MS lowered 5s → 2s for snappier updates.

All tests are passing now

image

🤖 Generated with Claude Code

- abortActorRun is awaited before callActorGetDataset returns, so a
  client notifications/cancelled actually aborts the run instead of
  fire-and-forget.
- Initial actor run status is sent through the progress tracker before
  waitForFinish, so the first status update reaches the client without
  the polling delay.
- PROGRESS_NOTIFICATION_INTERVAL_MS lowered 5s -> 2s for snappier
  progress.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added t-ai Issues owned by the AI team. tested Temporary label used only programatically for some analytics. labels May 1, 2026
@jirispilka jirispilka marked this pull request as draft May 1, 2026 19:43
@jirispilka jirispilka changed the title fix: Await actor run abort and report initial status promptly fix: Await actor run abort and report initial status May 1, 2026
@jirispilka jirispilka requested a review from Copilot May 1, 2026 21:34
@jirispilka jirispilka changed the title fix: Await actor run abort and report initial status fix: Report initial status and terminal status message (if saved) May 1, 2026
Copy link
Copy Markdown
Contributor

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

Improves reliability of Actor-run progress and cancellation behavior so clients consistently receive early and terminal status updates and cancellations actually abort the run before returning.

Changes:

  • Add terminal-aware Actor run status formatting and strengthen ProgressTracker to avoid duplicate emissions (seeded initial state, stopped guard, consecutive-message dedup).
  • Update callActorGetDataset to await abort requests on cancellation, emit an initial progress update immediately, and emit a final terminal update from a refreshed run snapshot.
  • Reduce progress polling interval from 5s to 2s and expand unit test coverage for the new behaviors.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/tools/core/actor_execution.ts Await abort on cancellation; emit initial + final progress messages; refresh run snapshot after completion.
src/utils/progress.ts Introduce formatRunStatusMessage; add dedup/stopped protections; seed polling dedup state.
src/const.ts Lower progress polling interval to 2 seconds.
tests/unit/tools.actor_execution.test.ts Add coverage for cancellation awaiting abort and for initial/final progress emission behavior.
tests/unit/utils.progress.test.ts Add coverage for dedup, seeded initial state, and stop-while-in-flight behavior; add formatter tests.
tests/integration/suite.ts Update commentary to reference the polling interval constant.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/tools/core/actor_execution.ts Outdated
Comment thread src/tools/core/actor_execution.ts
Comment thread src/utils/progress.ts
@jirispilka jirispilka marked this pull request as ready for review May 1, 2026 22:04
@jirispilka jirispilka requested a review from MQ37 May 1, 2026 22:04
Comment thread src/const.ts Outdated
@jirispilka jirispilka merged commit 0e41bb9 into master May 5, 2026
12 checks passed
@jirispilka jirispilka deleted the fix/actor-run-abort-and-progress branch May 5, 2026 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-ai Issues owned by the AI team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants