From d4d81af583f46f04526a1d79b00e8f37d3e7041c Mon Sep 17 00:00:00 2001 From: Giteabot Date: Sun, 5 Jul 2026 22:38:47 -0700 Subject: [PATCH] fix(actions): release claimed task if context is cancelled during `FetchTask` (#38343) (#38347) --- services/actions/task.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/services/actions/task.go b/services/actions/task.go index a76a981b50..f9e8e2d018 100644 --- a/services/actions/task.go +++ b/services/actions/task.go @@ -76,6 +76,15 @@ func PickTask(ctx context.Context, runner *actions_model.ActionRunner) (*runnerv NotifyWorkflowRunStatusUpdateWithReload(ctx, job.RepoID, job.RunID) } + // The job is claimed and its payload assembled, but if the request context was cancelled meanwhile, response can no longer reach the runner. + // Release the claim so another runner can pick the job up. + if err := ctx.Err(); err != nil { + if relErr := actions_model.ReleaseTaskForRunner(ctx, t); relErr != nil { + log.Error("ReleaseTaskForRunner [task_id: %d]: %v", t.ID, relErr) + } + return nil, false, err + } + return task, true, nil }