Skip to content

fix(eve): close custom worlds during graceful shutdown - #1390

Draft
bob-obringer wants to merge 3 commits into
vercel:mainfrom
bob-obringer:agent/close-dev-workers-gracefully
Draft

fix(eve): close custom worlds during graceful shutdown#1390
bob-obringer wants to merge 3 commits into
vercel:mainfrom
bob-obringer:agent/close-dev-workers-gracefully

Conversation

@bob-obringer

Copy link
Copy Markdown

Description

Custom Workflow worlds currently start in both production and development, but neither lifecycle reliably closes them:

  • the generated production World plugin has no Nitro close hook, and eve start does not route signals through that hook lifecycle;
  • a retired or final development worker is terminated without first sending env-runner's existing shutdown IPC event and awaiting its exit acknowledgement.

This draft makes the two halves one coordinated lifecycle:

  • generated World plugins register an idempotent Nitro close hook and await world.close?.();
  • self-hosted production signals run Nitro cleanup exactly once while srvx independently drains admitted HTTP work and waitUntil tasks; Eve sets the signal exit code without calling process.exit(), so neither path can truncate the other;
  • development workers receive shutdown, get up to 300 ms to acknowledge completion, and are then terminated as a bounded final reap if they are unresponsive.

The development grace period fits inside the CLI child's existing 550 ms IPC shutdown budget. Vercel and development-sandbox runtimes retain their existing lifecycle ownership.

This is distinct from #1142, which coordinates the outer CLI child process, and from #787/#790, which preserve admitted work while generations change. This change closes the custom resources owned inside those production and worker processes. It does not add crash recovery.

How did you test your changes?

  • pnpm fmt
  • pnpm lint
  • pnpm typecheck — 32/32 package tasks passed
  • pnpm guard:invariants
  • pnpm docs:check — 79 docs, 250 import paths across 333 code blocks, and 79 MDX files passed
  • pnpm check:deps
  • pnpm test:unit — 536 files, 5,656 passed, 1 skipped
  • pnpm test:integration — 84 files, 568 passed, 1 skipped
  • focused final lifecycle run — 3 unit files / 16 tests and 4 scenario files / 40 tests passed
  • packaged production regression — an admitted slow HTTP stream finishes across SIGTERM, the custom World releases its lock, and an immediate restart reacquires and releases it
  • development regression — HMR closes the retired worker's custom World, final shutdown closes the active World, immediate restart succeeds, and a never-settling close is force-reaped within the bound

The full scenario run passed 64/65 files (374 tests passed, 15 skipped). Two Next/Vercel assembly tests fail before building because Vercel CLI selects pnpm 10 and rejects ignored esbuild/sharp scripts. The same two failures reproduce unchanged on pristine origin/main; all lifecycle scenario files pass.

PR Checklist

  • I linked an issue with prior discussion confirming this change is wanted
  • I ran the relevant checks from CONTRIBUTING.md
  • I added tests and documentation where relevant
  • I added a changeset if this touches the published eve package
  • DCO sign-off passes for every commit (git commit --signoff)

Signed-off-by: Bob Obringer <bob@neynar.com>
Signed-off-by: Bob Obringer <bob@neynar.com>
@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@bob-obringer is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

Signed-off-by: Bob Obringer <bob@neynar.com>
@bob-obringer
bob-obringer force-pushed the agent/close-dev-workers-gracefully branch from 4c9783f to 6f0f073 Compare July 30, 2026 01:53
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