Skip to content

Reclaim half-open worker sockets before the lease fails the run - #13

Merged
cursor[bot] merged 1 commit into
masterfrom
dougrathbone/worker-lease-takeover-c6d6
Oct 14, 2026
Merged

cursor[bot] merged 1 commit into
masterfrom
dougrathbone/worker-lease-takeover-c6d6

Conversation

@dougrathbone

Copy link
Copy Markdown
Owner

Fixes CONDUIT-S

A Fargate worker that reconnects with the same workerId was rejected with close 4002 while the previous socket still held the assignment. A half-open socket never emits close and never answers a ping, so the real worker could not take the connection back. About 75 seconds later the lease expired and the run failed with lost contact.

On worker:hello, if the claimed run ids intersect that worker's assignments, the server now pings the old socket (300ms). A pong keeps the existing reject-the-duplicate behavior, including the impostor case where the new hello does not claim the active run. No pong means the peer is dead: the server terminates it, moves the assignments onto the new socket, and continues adoption without failing the run.

npx vitest run src/server/workerControl.test.ts — 53 passed.

Open in Web Open in Cursor 

When a worker hellos with the same workerId while the prior socket still
holds assignments, probe that socket with a short WebSocket ping. If it
pongs, keep rejecting the duplicate (4002). If it does not, terminate the
dead peer, bind assignments to the new socket, and continue adoption so
Fargate reconnects can beat the lease instead of failing with lost contact.

Fixes CONDUIT-S
@cursor
cursor Bot merged commit 90365e5 into master Oct 14, 2026
1 check passed
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.

2 participants