Skip to content

refactor(server): use Latch for shutdown gate - #43571

Merged
kitlangton merged 1 commit into
v2from
latch-server-shutdown
Aug 20, 2026
Merged

refactor(server): use Latch for shutdown gate#43571
kitlangton merged 1 commit into
v2from
latch-server-shutdown

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

What

The server process's shutdown signal is a pure "shutdown requested" gate — a Deferred<void> that is only ever succeeded and awaited. Latch states that intent directly: a valueless, never-failing open-once signal.

How

packages/server/src/process.ts:

  • shutdown is now yield* Latch.make() (starts closed).
  • The lifecycle callback receives shutdown.open.pipe(Effect.asVoid) instead of Deferred.succeed(...).pipe(Effect.asVoid).
  • Both waiters (shutdown handle returned to callers, and the raceFirst against boot) use shutdown.await.

No behavior change. Found by a repo-wide audit of Deferred<void>-as-gate patterns; sibling PRs convert the other pure-gate sites.

Testing

  • packages/server: bun typecheck, full bun run test (22 pass / 0 fail).

@kitlangton
kitlangton merged commit 4651bd1 into v2 Aug 20, 2026
10 checks passed
@kitlangton
kitlangton deleted the latch-server-shutdown branch August 20, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant