0
Fork 0
mirror of https://github.com/mastra-ai/mastra.git synced 2026-11-17 08:44:46 +00:00

fix(mcp): keep workflow runs going when their server shuts down

An attempt's abort cancelled its workflow run, but the background task manager also aborts
attempts when it shuts down or loses a task to another worker. A graceful shutdown or a
lease loss therefore cancelled runs that should have carried on, and the task completed
with "run was cancelled".

- Aborting an attempt now only stops following the run. The run is cancelled only by a
  declined answer or the store's onCancel (tasks/cancel, TTL expiry). A run executing in
  this process is stopped through a process-local registry; one executing elsewhere is left
  alone; one that waits is cancelled in storage.
- A row whose worker shut down gracefully is left `running` with its lease released. The
  MCP sweep only reclaimed lapsed leases, so the task never got picked up again. It now
  reclaims a running row with no lease too, as core's own stale recovery does.
- A resume that fails because the run was resumed elsewhere after the pre-check now re-reads
  the run and follows it if the answered suspension is gone.

Co-Authored-By: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
This commit is contained in:
Daniel Lew 2026-10-27 16:09:10 -04:00
commit fedc469d97
6 changed files with 102 additions and 34 deletions