Repository navigation
Conversation
tasks/list returned tasks whose owning instance had died as `working`; only tasks/get and tasks/result ran the owner-lost check. Run the same failIfOwnerLost check on every entry of the page, with bounded concurrency, so a lapsed lease is reported (and recorded) as `failed` consistently across all three methods. Fixes #330 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LmhsFjk8W96X2PvmShmDm9
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tasks/listreported a task whose owning instance had died asworking. Onlytasks/getandtasks/resultran the owner-lost check, so the list disagreed with them until one of those was called.Fix
handleTasksListnow runsfailIfOwnerLoston each task in the page, at most 8 at a time. Terminal tasks and tasks with no lease return straight away with no store round trip, so only non-terminal leased tasks cost afailExpiredLeasecall. A task deleted during the check is dropped from the page.Why the handler and not
store.listfailIfOwnerLostalso callstaskWaiters.notify(), which wakestasks/resultcallers on this instance. The store has no access to the waiters.tasks/getandtasks/resultalready reap in the handler through the store'sfailExpiredLeasecompare-and-set, using the store clock (the Redis server clock for Redis). Doing the same here keeps one code path for every backend, including customTaskStoreimplementations, and leaves theTaskStorecontract unchanged.Tests
test/tasks.test.ts) and Redis (test/redis-task-integration.test.ts): with auth on andtaskLeaseMsshort, start a task that never finishes, mockrenewLeaseso it stops renewing (a simulated crash), wait for the lease to lapse, then calltasks/list. The task comes backfailedwith the owner-lost message and noleaseExpiresAt. Both tests failed before the fix.npm run lint,npm run typecheckand the fullnpm run testall pass (768/768).Fixes #330
🤖 Generated with Claude Code
https://claude.ai/code/session_01LmhsFjk8W96X2PvmShmDm9