Skip to content

fix(runners): preserve stopped status when Run returns after termination#3977

Draft
cursor[bot] wants to merge 1 commit into
developfrom
cursor/critical-bug-investigation-7a96
Draft

fix(runners): preserve stopped status when Run returns after termination#3977
cursor[bot] wants to merge 1 commit into
developfrom
cursor/critical-bug-investigation-7a96

Conversation

@cursor

@cursor cursor Bot commented Jun 18, 2026

Copy link
Copy Markdown

Bug and impact

When the server tells a runner to emergency-stop a task (terminated_jobs from progress sync, or a stop while the job is running), applyTerminatedJobs correctly sets the job status to stopped and kills the process. If Executor.Run then returns an error from the interrupted process, the runner's post-Run handler overwrote stopped with failed.

User-facing impact: Force-stopped or reassigned tasks were reported back to the server as failed instead of stopped, triggering wrong alerts, workflow edges, and task history.

Root cause

Commit 2a156b30 (fix(runners): logs) moved the IsFinished() early return from before the error handler into the success-only branch. On the error path, any non-stopping status — including already-stopped — was downgraded to failed.

Fix and validation

  • Extract completeAfterRun with the same guards used server-side (IsFinished, IsKilled, stoppingstopped).
  • Add regression tests covering terminated/stopped, killed, launch failure, and success paths.
go test ./services/runners/ -run TestRunningJob_completeAfterRun -v -count=1
Open in Web View Automation 

Commit 2a156b3 moved the post-Run IsFinished early return into the
success-only branch. When applyTerminatedJobs (or a server-side stop)
already marked a job stopped and Run returned an error from the killed
process, completeAfterRun overwrote stopped with failed.

Restore the finished/killed guards on the error path and add regression
tests.

Co-authored-by: Denis Gukov <fiftin@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant