Skip to content

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

Open
kitlangton wants to merge 1 commit into
v2from
latch-server-shutdown
Open

refactor(server): use Latch for shutdown gate#43571
kitlangton wants to merge 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).

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