Skip to content

Fix Fargate worker lease failures and stop-timeout storms - #12

Merged
cursor[bot] merged 1 commit into
masterfrom
dougrathbone/fix-fargate-worker-failures-e61a
Sep 29, 2026
Merged

cursor[bot] merged 1 commit into
masterfrom
dougrathbone/fix-fargate-worker-failures-e61a

Conversation

@dougrathbone

@dougrathbone dougrathbone commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

Production Conduit errors over the last week are one failure chain, plus one user credential warning.

Sentry (project Conduit, unresolved): issue list. Datadog has no Conduit service logs; the narrative is in Sentry breadcrumbs.

  • CONDUIT-S / CONDUIT-R — worker fargate-d23f292f-922c-478f-a55c-19d347cac0ee went silent. The server was idle (memory and disk checks only) until the 75s lease expired, then the run was failed with exit signal and last line lost contact (lease expired).
  • CONDUIT-Y — after a server restart on 2026-09-28, fargate worker fargate-f0d6629f-6b1b-4eb1-b285-84025b5a503b never dialed back. The orphan timer fired at exactly 300000ms. Breadcrumbs show no worker connection in that window.
  • CONDUIT-N / CONDUIT-T — the same task (7f5db4ff…, run d23f292f…) was described against ECS every ~2s for about nine minutes and never reached STOPPED. Each 60s slice was reported (waitUntilStopped), then "giving up after 3 attempts". The same pattern repeats across several runs since mid-September. ECS StopTask had already been accepted; Fargate stays in DEACTIVATING / DEPROVISIONING for minutes while the ENI detaches, and a 60s cap false-fails that wait.
  • CONDUIT-P — one Cursor run exited 1 with The provided API key is invalid. That is a bad stored credential, not a worker bug. Left as a warning.

A half-open control-plane socket keeps readyState OPEN and never emits close. Heartbeat write failures were swallowed, so the worker did not reconnect before the server lease (or the post-restart adoption window) failed the run.

Changes

  • Worker liveness: ping on each heartbeat, and drop the socket if the pong times out (10s) or the heartbeat write fails. The close handler reconnects inside the 75s lease and the 5 minute restart window.
  • Fargate stop: once ECS has accepted the stop (desiredStatus STOPPED, or DEACTIVATING / STOPPING / DEPROVISIONING), poll until STOPPED for up to 10 minutes. A task that stays RUNNING is still retried. Sentry is notified once, and the message includes the status ECS returned. Shutdown still aborts the wait at its own deadline.

Fixes CONDUIT-N
Fixes CONDUIT-T
Fixes CONDUIT-S
Fixes CONDUIT-R
Fixes CONDUIT-Y

Test

  • npm run build — Vite renderer plus tsc server/worker output. Source-map upload skipped (no Sentry upload credentials).
  • npx vitest run src/server/workers/fargateWorker.test.ts src/worker/liveness.test.ts (51 passed)
  • npx tsc --noEmit --project tsconfig.server.json
  • npm run e2e:fargate — 50 driver checks, 9 server-replacement restart checks, shutdown cleanup, and 11 reconnect-expiry checks, all passed. Covers task stop, SIGKILL of the server with the worker reconnecting, graceful SIGTERM stopping every simulated task, and the reconnect-timeout diagnostic.
Open in Web Open in Cursor 

…rovision

A half-open worker socket stayed open and swallowed failed heartbeats, so
the server lease expired and failed the run, and a replaced server never
saw the worker dial back. Ping the peer and drop the socket when the pong
or the heartbeat write fails.

Stop verification treated DEPROVISIONING as a missed stop every 60s.
Poll an accepted stop until the task is STOPPED, and report a stuck task
once with the status ECS returned.

Fixes CONDUIT-N
Fixes CONDUIT-T
Fixes CONDUIT-S
Fixes CONDUIT-R
Fixes CONDUIT-Y

Co-authored-by: Doug Rathbone <dougrathbone@users.noreply.github.com>
@dougrathbone
dougrathbone marked this pull request as ready for review September 29, 2026 10:03
@cursor
cursor Bot merged commit b10e383 into master Sep 29, 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.

1 participant