GeezerVison is showing github.com — mcpx(tasks): grace expiry records Cancelled but never closes done — Result() waiters are not released · Issue #6897 · developing-today/code
mcpx(tasks): grace expiry records Cancelled but never closes done — Result() waiters are not released #6897DescriptionFinding
When a task's cooperative cancellation grace period expires, expireCancellation() records the task as Cancelled — but it never closes the task's done channel, so a caller blocked in Store.Result() is not released by the expiry. Result() waiters are only released when the underlying work eventually returns (the worker goroutine closes done), which is exactly what does not happen for the uncooperative work the grace mechanism exists for.
Evidence
- Source PR: mcpx: give tasks honest cancellation and error endings (#2499) #3699 (merged, merge
687ac07a84d9ed9cf737473de52f9419ee348927, head f8470369c2e8342c07ab262aff4bdf6a0918eb31) — it introduced the cancel-grace timer and expireCancellation().
pkgs/mcpx/internal/tasks/tasks.go on current main (4cd2927643453bee47a0f764de534e229220cf88, verified twice via the contents API):
expireCancellation at line 1208 sets t.Status = Cancelled, arms retention, saves, and calls s.changed(...) — no close(t.done) anywhere in the function.
Result at line 1261 blocks on case <-t.done: (line ~1269); it returns the "task was cancelled" fault only after done closes.
- The only
close(t.done) calls are line 457 (load-time reconstruction of already-terminal rows) and line 904 (the worker goroutine, after fn(ctx) returns).
- The code itself states the contract at line ~1198: "a watcher may wait on the task's completion (Store.Result waits for done)".
- mcpx: give tasks honest cancellation and error endings (#2499) #3699's grace-expiry test does not catch this: it releases the work before calling
Result(), so done is closed by the worker path, not by the expiry path.
Why it matters
The grace expiry is the terminal guarantee for work that ignores cancellation: Get() reports Cancelled and retention starts, yet any client waiting in Result() hangs until its own context expires. The task's recorded state and its wait semantics disagree, on precisely the path designed for uncooperative work.
Acceptance criteria
- When
expireCancellation records Cancelled, waiters in Result() are released promptly and observe the cancelled fault, without the work returning.
-
done is closed at most once across all terminal paths (worker finish, immediate cancel, grace expiry, load reconstruction) — no double-close panic under -race.
- A regression test covers grace expiry while the work never returns:
Result() unblocks with the cancelled fault.
- Existing tasks tests still pass (
go test ./internal/tasks/, race included via CI).
Activitydeveloping-today commented on Nov 7, 2026 developing-today commented on Nov 8, 2026 developing-today commented on Nov 8, 2026 Agent note - parked
- Agent: queue worker (repo-worker-code), lane code-k
- Session / ID: task 11296
- Found via: queue claim
- Task: Parked task 11296 (issue mcpx(tasks): grace expiry records Cancelled but never closes done — Result() waiters are not released #6897) for 1200s on CI/Codex for PR mcpx(tasks): close done on grace expiry so Result waiters are released #7041. Triage verified on fresh main 9bb7f19 (expireCancellation records Cancelled, no close(t.done)); regression test reproduced the hang (Result waiter context deadline), fix implemented: mu-guarded once-only closeDone, grace expiry closes done, worker close is once-only, CancelImmediate unchanged. Commit 45bf2d8. Tests: go test ./internal/tasks/ -race full package PASS, go vet clean.
- Expectation: on resume, check PR mcpx(tasks): close done on grace expiry so Result waiters are released #7041 checks + Codex findings, merge, then complete task 11296.
- Links: issue mcpx(tasks): grace expiry records Cancelled but never closes done — Result() waiters are not released #6897, PR mcpx(tasks): close done on grace expiry so Result waiters are released #7041 mcpx(tasks): close done on grace expiry so Result waiters are released #7041
developing-today commented on Nov 8, 2026 🤖 Agent note · parked
- Agent: queue worker (repo-worker-code), lane code-q
- Session / ID: task 11296
- Found via: queue claim (direct execution lane), resuming from checkpoint "checks + Codex on PR mcpx(tasks): close done on grace expiry so Result waiters are released #7041, then merge and complete"
- Task: Triage/fix for issue mcpx(tasks): grace expiry records Cancelled but never closes done — Result() waiters are not released #6897 (mcpx tasks: grace expiry records Cancelled but never closes done). PR mcpx(tasks): close done on grace expiry so Result waiters are released #7041 is OPEN on branch queue/11296-6897-grace-expiry-done, head 45bf2d8; diff matches intent (pkgs/mcpx/internal/tasks/tasks.go +30/-2, tasks_test.go +35). Codex: no review or findings posted on PR mcpx(tasks): close done on grace expiry so Result waiters are released #7041 as of 2026-11-08T02:44Z — nothing undispositioned. CI has not completed: the three basic checks (scripts-test 3.12/3.14, proxy port fallbacks) have been QUEUED since 2026-11-08T01:54Z with no runner pickup (CodeRabbit skipped/completed) — the same runner stall as PR ci(check-workflows): validate node runs.main and composite step shapes #7020, not a failure of this change.
- Expectation: task 11296 parked 20 minutes per the CI rule; on resume, if checks are green and no Codex findings have appeared, merge PR mcpx(tasks): close done on grace expiry so Result waiters are released #7041, close issue mcpx(tasks): grace expiry records Cancelled but never closes done — Result() waiters are not released #6897, and complete task 11296.
- Links: issue mcpx(tasks): grace expiry records Cancelled but never closes done — Result() waiters are not released #6897, PR mcpx(tasks): close done on grace expiry so Result waiters are released #7041
dezren39 commented on Nov 9, 2026
Agent note — lane code-w, task 11296
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|