You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[service] Processes do not exit after a drain, and nothing closes KV or Prisma #2630
After a completed or timed-out drain, background children and services return from their entry point but never end the process. No role closes its KV, Prisma or Redis handles, so whether the process exits depends on which handles happen to stay open.
packages/plugin/src/presentation/run-child-health-process.ts:131-143: on a stop signal it awaits completion, removes the signal listeners, shuts the health server down and returns. Only the fatal path throws. The comment on line 141 already says "Bootstrap may leave dependency handles alive".
packages/service/src/builder/service-listener.ts and service-shutdown.ts: the 30 s drain timeout (DEFAULT_DRAIN_TIMEOUT_MS) returns { timedOut: true } and logs a warning. Nothing forces an exit.
closeKv() (packages/kv/application/shared.ts:187) has no runtime caller outside the KV package. Prisma is disconnected only for the health-check client in defineService. The workers child opens KV in plugins/workers/bin/runtime.ts and never closes it.
The only Deno.exit in runtime code is the opt-in OTel SDK provider (packages/telemetry/src/adapters/otel/otel-sdk.ts), which can exit 0 before the drain ends.
Not verified by running: which handle keeps the event loop alive in practice.
Expected behavior
After a drain, each role closes the handles it opened (KV, Prisma, Redis connections) and the process ends with a defined exit code: 0 for a clean drain, non-zero for a timed-out drain or a fatal child.
Acceptance
A background child started through runChildHealthProcess exits on SIGTERM within its drain budget, proven by a subprocess test that fails on current main.
A service started through serve() exits after a completed drain and after a timed-out drain, with distinct exit codes, proven by a subprocess test.
Each role closes the KV, Prisma and Redis handles it opened before it exits.
Activity