Repository navigation
Bug: A queued heartbeat run for a closed issue is declined at claim forever (~20 claim_declined warnings per minute for 8 days) and never settled
#22687
haakjesluiten
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Bug report (posted as a discussion: the issue form requires confirming the latest release or a reproduction on master; this was observed on
2026.1116.0-nightly.0and the code path was re-read, unchanged, onmastere856a607, but not reproduced there).Version
@paperclipai/server2026.1116.0-nightly.0, commit278660149, self-hosted.mastere856a607: same behaviour.Observed
queuedfor 8.3 days. Its issue was alreadydonefor that whole period.claimQueuedRun()returnednull, and the server logged the warning "long-queued heartbeat run was offered a free slot but could not be claimed; it stays queued and the next oldest run takes its turn" withreason: "claim_declined".issue_commented(wakeSource/source:issue.comment,invocationSource: automation,triggerDetail: system). It was created while the issue was still open; the issue was done by 2026-11-15, the run never started (startedAtnull), and it was finally cancelled witherrorCode: agent_paused. Sinceissue_commentedis not inSYSTEM_CONTINUATION_WAKE_REASONS, the closed-task cancel inclaimQueuedRunnever applies to it.Expected
done,cancelled) and that carries no undelivered person message is cancelled (or skipped) with a recorded outcome, the same wayCLOSED_TASK_CONTINUATIONalready settles system continuations.Code pointer (
mastere856a607)server/src/services/heartbeat/queue.ts, inclaimQueuedRunsForAgent()(~L2683):noteDeclinedAgedClaim()(~L2470) only logs; it never cancels:The only closed-task cancel inside
claimQueuedRun()(~L1050-1073) is limited toSYSTEM_CONTINUATION_WAKE_REASONS(~L958:issue_recovery_action_restored,issue_continuation_needed,issue_assignment_recovery, the blocker-stalled reason,issue_children_completed). It also leaves the run queued whencancelClosedTaskContinuation()returnsstill_queuedorcarries_person_message. Every other wake reason on a closed issue falls through to one of the ~30 otherreturn nullpaths inclaimQueuedRun(), and the dispatch pass treats all of them as a plain decline.Why the backoff does not hold (inferred from the code, not measured):
claimBackedOff()only honours a backoff whilebackoff.taskStamp === taskStamp; the stamp isstatus:updatedAt:executionRunIdof the issue, so any write to the issue resets the backoff.retryRefusedskip the backoff check entirely (!retryRefused && claimBackedOff(...)).noteDeclinedAgedClaim()logs on every decline;declinedAgedClaimAtis written but not used to suppress the log.Suggested minimal fix
!claimedbranch (or at the top ofclaimQueuedRun()), if the run's issue is in a terminal state and the run carries no undelivered person message, cancel it with an expliciterrorCode(for examplequeued_run_issue_closed), skip its wake, and callreleaseIssueExecutionAndPromote(), the same settle shape used forCLOSED_TASK_CONTINUATION. Do this for every wake reason, not onlySYSTEM_CONTINUATION_WAKE_REASONS.claim_declinedwarning per run (for example: log the first decline, then at most once perQUEUED_RUN_AGING_MS, with an attempt counter), using the existingdeclinedAgedClaimAtmap.queuedruns (see Queued runs have no age bound: one never-started run silently suppressed a cron routine's entire schedule for 65h (60 consecutivecoalescedticks) #17955) that cancels with a recorded outcome.Related / possible duplicates
claim_declined+backOffClaimmax 60 s, run never settled), but for a native review run whose review assignment is gone. Fix in PR fix(heartbeat): settle a queued native review run whose assignment is gone #22620 (open) covers only that case.A queued native review run whose review assignment is gone is never settled at claim #22350
fix(heartbeat): settle a queued native review run whose assignment is gone #22620
coalescedticks) #17955 (open): queued runs have no age bound (general watchdog request).Queued runs have no age bound: one never-started run silently suppressed a cron routine's entire schedule for 65h (60 consecutive
coalescedticks) #17955Reassigning an issue does not cancel the previous assignee's queued run, so the new assignee's wake stays deferred #14879
claim_declined.All reactions