Depends on #141 (CARD-21). Review and merge after it. This branch stacks on feature/fprd-001c-mesh-reserved-path, so until #141 merges the diff also shows its two commits. The CARD-17 change is the single commit feat(http): liveness and readiness probes with a drain window (CARD-17, #115).
What and why
CARD-17 (core #115), decision D14 (health: true | { drainDelayMs?: number }; probes bypass shedding; the edge never reports draining).
createApp({ health }), off by default. GET/HEAD /__live__ returns 200 {"status":"ok"}. /__ready__ returns:
503 booting until boot() resolves,
then 200 ok or 200 degraded with degraded: [...] from app.degraded(),
then 503 draining from the first line of close().
Where probes are answered (src/http/health.ts, new): ahead of the request gate and handle().
Node: in serve() (src/http/server.ts, the writeProbe helper).
Fetch: in app.fetchbefore it awaits the boot (answerFetchProbe in src/http/web.ts). That is the only place /__ready__ can still say booting.
Because probes never reach the gate or the pipeline, they are never shed, run no step, provider, plugin or onError, and emit no lifecycle event. Security headers are still merged in, plus cache-control: no-store. Other methods get 405 with Allow: GET, HEAD.
State: trackHealth wraps the memoised boot, so a resolved boot moves the app to ready. drain() sets draining and holds for drainDelayMs, once. The phase only moves forward.
Drain:
Node app.close() drains first. The window is spent out of the close budget, so close() still returns within timeoutMs.
serveDeno/serveBunclose() call the same drain through a symbol-keyed hook on the app (HEALTH_DRAIN, not public API) before server.shutdown() / server.stop(false).
workerd has no close(), so it never reports draining.
Reserved paths: while health is on, /__live__ and /__ready__ join the boot check CARD-21 introduced (src/http/reserved-paths.ts), for local and mesh-spliced routes. With health off they are ordinary paths.
Validation: createApp throws on any health other than true, false or { drainDelayMs?: number }. That includes unknown keys such as checks, a negative or non-finite delay, and drainDelayMs + teardownTimeoutMs > shutdownTimeoutMs.
JSDoc on the option and on App.close(). README bullet. CHANGELOG under ### Added.
Choices the card left open: please confirm
A probe through app.fetch before any boot starts the boot without waiting for it. Without this, on the edge or under a bare Deno.serve(app.fetch), an orchestrator that waits for ready before sending traffic would see booting forever, because only a real request would boot the app. The rejection is swallowed only on the probe path; the boot memo keeps it, so real requests still fail with it.
A failed boot leaves /__ready__ at 503 booting. The card has no failed state, and I didn't invent one.
The drain window comes out of the shutdown budget, matching how teardownTimeoutMs is carved out. A drainDelayMs that can't fit throws at createApp, the way teardownTimeoutMs > shutdownTimeoutMs already does. The card only says "invalid health throws", so this bound is my addition.
Only the exact paths are probes./__ready__/ (trailing slash) goes to the route table as usual. A query string is ignored.
On the Node listener and serveDeno/serveBun the app boots before it binds, so booting is only observable through app.fetch (T1). Both runtimes run T5 and see ok and draining. T2 and T3 run through shared code on Node.
Bun's stop(false) and Deno's shutdown() behaviour after the window is unchanged; D14's runtime limits apply.
Test evidence (local, on develop with #134 and #135)
test/health.test.ts:
T1 (slow provider: booting then ok, and a probe starting the boot), T2, T3
T4 on Node: a kept-alive probe connection gets 503 draining during close() while /slow completes 200. With drainDelayMs: 0 the same test gets ECONNRESET, which is D14's rationale, checked by hand.
T6 (maxConcurrentRequests: 1 saturated: probes 200, others 503), T7 (POST 405 with Allow; HEAD with no body)
T8 (@Get('/__live__') boot error, exact message), /__ready__ HTTP and WS with health on and off, teapot route at /__ready__
T9 (10 probes with logRequests: no log line, bus.emit never called, a plugin step never runs, with a control request)
invalid values, and the budget check
T5 runs in test/deno/shutdown.test.ts and test/bun/shutdown.test.ts. T10 runs in test/edge/run.ts: live 200, ready booting then ok with only probes reaching the isolate.
npm run lint 0 errors (52 warnings, unchanged: no-explicit-any)
npm run format:check All matched files use Prettier code style!
npm run typecheck clean
npm test Test Files 94 passed (94) · Tests 946 passed (946)
npm run build CJS/ESM/DTS build success
npm run complexity:check every function <= 25
npm run test:deno 38 passed | 0 failed
npm run test:bun 28 pass · 0 fail
npm run test:edge ... + reserved path + health — PASS; router parity 1158 + 55 — PASS
npm audit --audit-level=moderate found 0 vulnerabilities
Docs follow-up (CARD-12)
reference/createapp.md: the health option: shape, states and bodies, 405, cache-control, drainDelayMs and its budget rule, the probe-starts-boot behaviour. Add /__live__ and /__ready__ to the reserved-paths list started for CARD-21.
Deployment and shutdown guide: Kubernetes and load-balancer readiness with drainDelayMs versus a platform preStop sleep (PRD open question), why Node needs the window (idle keep-alive sockets close at once), and Deno/Bun close() behaviour.
Runtimes page: the edge never reports draining, and booting is per isolate.
**Depends on #141 (CARD-21). Review and merge after it.** This branch stacks on `feature/fprd-001c-mesh-reserved-path`, so until #141 merges the diff also shows its two commits. The CARD-17 change is the single commit `feat(http): liveness and readiness probes with a drain window (CARD-17, #115)`.
## What and why
CARD-17 (core #115), decision **D14** (`health: true | { drainDelayMs?: number }`; probes bypass shedding; the edge never reports draining).
- `createApp({ health })`, off by default. `GET`/`HEAD /__live__` returns `200 {"status":"ok"}`. `/__ready__` returns:
- `503 booting` until `boot()` resolves,
- then `200 ok` or `200 degraded` with `degraded: [...]` from `app.degraded()`,
- then `503 draining` from the first line of `close()`.
- **Where probes are answered** (`src/http/health.ts`, new): ahead of the request gate and `handle()`.
- Node: in `serve()` (`src/http/server.ts`, the `writeProbe` helper).
- Fetch: in `app.fetch` **before it awaits the boot** (`answerFetchProbe` in `src/http/web.ts`). That is the only place `/__ready__` can still say `booting`.
- Because probes never reach the gate or the pipeline, they are never shed, run no step, provider, plugin or `onError`, and emit no lifecycle event. Security headers are still merged in, plus `cache-control: no-store`. Other methods get `405` with `Allow: GET, HEAD`.
- **State**: `trackHealth` wraps the memoised boot, so a resolved boot moves the app to ready. `drain()` sets draining and holds for `drainDelayMs`, once. The phase only moves forward.
- **Drain**:
- Node `app.close()` drains first. The window is spent out of the close budget, so `close()` still returns within `timeoutMs`.
- `serveDeno`/`serveBun` `close()` call the same drain through a symbol-keyed hook on the app (`HEALTH_DRAIN`, not public API) before `server.shutdown()` / `server.stop(false)`.
- workerd has no `close()`, so it never reports draining.
- **Reserved paths**: while `health` is on, `/__live__` and `/__ready__` join the boot check CARD-21 introduced (`src/http/reserved-paths.ts`), for local and mesh-spliced routes. With health off they are ordinary paths.
- **Validation**: `createApp` throws on any `health` other than `true`, `false` or `{ drainDelayMs?: number }`. That includes unknown keys such as `checks`, a negative or non-finite delay, and `drainDelayMs + teardownTimeoutMs > shutdownTimeoutMs`.
- JSDoc on the option and on `App.close()`. README bullet. `CHANGELOG` under `### Added`.
## Choices the card left open: please confirm
1. **A probe through `app.fetch` before any boot starts the boot without waiting for it.** Without this, on the edge or under a bare `Deno.serve(app.fetch)`, an orchestrator that waits for ready before sending traffic would see `booting` forever, because only a real request would boot the app. The rejection is swallowed only on the probe path; the boot memo keeps it, so real requests still fail with it.
2. **A failed boot leaves `/__ready__` at `503 booting`.** The card has no failed state, and I didn't invent one.
3. **The drain window comes out of the shutdown budget**, matching how `teardownTimeoutMs` is carved out. A `drainDelayMs` that can't fit throws at `createApp`, the way `teardownTimeoutMs > shutdownTimeoutMs` already does. The card only says "invalid health throws", so this bound is my addition.
4. **Only the exact paths are probes.** `/__ready__/` (trailing slash) goes to the route table as usual. A query string is ignored.
5. On the Node listener and `serveDeno`/`serveBun` the app boots before it binds, so `booting` is only observable through `app.fetch` (T1). Both runtimes run T5 and see ok and draining. T2 and T3 run through shared code on Node.
6. Bun's `stop(false)` and Deno's `shutdown()` behaviour after the window is unchanged; D14's runtime limits apply.
## Test evidence (local, on develop with #134 and #135)
`test/health.test.ts`:
- T1 (slow provider: booting then ok, and a probe starting the boot), T2, T3
- T4 on Node: a kept-alive probe connection gets `503 draining` during `close()` while `/slow` completes `200`. With `drainDelayMs: 0` the same test gets `ECONNRESET`, which is D14's rationale, checked by hand.
- T6 (`maxConcurrentRequests: 1` saturated: probes `200`, others `503`), T7 (POST `405` with `Allow`; HEAD with no body)
- T8 (`@Get('/__live__')` boot error, exact message), `/__ready__` HTTP and WS with health on and off, teapot route at `/__ready__`
- T9 (10 probes with `logRequests`: no log line, `bus.emit` never called, a plugin step never runs, with a control request)
- invalid values, and the budget check
T5 runs in `test/deno/shutdown.test.ts` and `test/bun/shutdown.test.ts`. T10 runs in `test/edge/run.ts`: live 200, ready booting then ok with only probes reaching the isolate.
```
npm run lint 0 errors (52 warnings, unchanged: no-explicit-any)
npm run format:check All matched files use Prettier code style!
npm run typecheck clean
npm test Test Files 94 passed (94) · Tests 946 passed (946)
npm run build CJS/ESM/DTS build success
npm run complexity:check every function <= 25
npm run test:deno 38 passed | 0 failed
npm run test:bun 28 pass · 0 fail
npm run test:edge ... + reserved path + health — PASS; router parity 1158 + 55 — PASS
npm audit --audit-level=moderate found 0 vulnerabilities
```
## Docs follow-up (CARD-12)
- `reference/createapp.md`: the `health` option: shape, states and bodies, 405, `cache-control`, `drainDelayMs` and its budget rule, the probe-starts-boot behaviour. Add `/__live__` and `/__ready__` to the reserved-paths list started for CARD-21.
- Deployment and shutdown guide: Kubernetes and load-balancer readiness with `drainDelayMs` versus a platform `preStop` sleep (PRD open question), why Node needs the window (idle keep-alive sockets close at once), and Deno/Bun `close()` behaviour.
- Runtimes page: the edge never reports `draining`, and booting is per isolate.
Owner decisions (2026-10-23): probe-triggered boot, 503 booting on failed boot, and the drain-vs-shutdown-timeout check are accepted. Not merging yet: implementation review first.
Owner decisions (2026-10-23): probe-triggered boot, `503 booting` on failed boot, and the drain-vs-shutdown-timeout check are accepted. Not merging yet: implementation review first.
Implementation review done on 2026-10-23: a Codex review of all 12 sprint PRs, with each finding verified. The P1s in #142 and the P3 in #149 are fixed. The owner (Chrnx) authorized merging in order, each one rebased on develop with CI green. This supersedes the earlier "not merging yet" note.
Implementation review done on 2026-10-23: a Codex review of all 12 sprint PRs, with each finding verified. The P1s in #142 and the P3 in #149 are fixed. The owner (Chrnx) authorized merging in order, each one rebased on develop with CI green. This supersedes the earlier "not merging yet" note.
createApp({ health: true }) serves GET/HEAD /__live__ and /__ready__.
Ready reports booting until boot() resolves, ok or degraded (from
app.degraded()) after that, and draining from the moment close() starts.
Probes are answered by the adapters, ahead of the request gate and of
handle(): Node in serve() (src/http/server.ts), the Fetch path in
app.fetch before it awaits the boot. Otherwise ready could never say
booting. Being ahead of the gate means maxConcurrentRequests never sheds
a probe (D14). Being ahead of handle() means no step, provider, plugin or
onError runs, and no lifecycle event is emitted, so logRequests and
metrics never see a probe. Security headers still apply, plus
cache-control: no-store. Other methods get 405 with Allow: GET, HEAD.
A probe through app.fetch before any boot starts the boot without
awaiting it. On the edge, or under a bare Deno.serve(app.fetch), nothing
else may boot the app, and an orchestrator that waits for ready before
sending traffic would wait forever.
health: { drainDelayMs } (D14) marks the app draining and keeps the
listener open for that long before connections drain. Without it, Node
closes idle keep-alive sockets at once, and a probe sees a reset rather
than the 503. The window is spent out of the close budget. serveDeno and
serveBun start the same window, through a symbol-keyed hook on the app,
before server.shutdown() / server.stop(false). workerd has no close(),
so it never reports draining.
While health is on, /__live__ and /__ready__ join the reserved-path
boot check that CARD-21 introduced, for local and mesh-spliced routes.
Invalid health values throw at createApp.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Depends on #141 (CARD-21). Review and merge after it. This branch stacks on
feature/fprd-001c-mesh-reserved-path, so until #141 merges the diff also shows its two commits. The CARD-17 change is the single commitfeat(http): liveness and readiness probes with a drain window (CARD-17, #115).What and why
CARD-17 (core #115), decision D14 (
health: true | { drainDelayMs?: number }; probes bypass shedding; the edge never reports draining).createApp({ health }), off by default.GET/HEAD /__live__returns200 {"status":"ok"}./__ready__returns:503 bootinguntilboot()resolves,200 okor200 degradedwithdegraded: [...]fromapp.degraded(),503 drainingfrom the first line ofclose().src/http/health.ts, new): ahead of the request gate andhandle().serve()(src/http/server.ts, thewriteProbehelper).app.fetchbefore it awaits the boot (answerFetchProbeinsrc/http/web.ts). That is the only place/__ready__can still saybooting.onError, and emit no lifecycle event. Security headers are still merged in, pluscache-control: no-store. Other methods get405withAllow: GET, HEAD.trackHealthwraps the memoised boot, so a resolved boot moves the app to ready.drain()sets draining and holds fordrainDelayMs, once. The phase only moves forward.app.close()drains first. The window is spent out of the close budget, soclose()still returns withintimeoutMs.serveDeno/serveBunclose()call the same drain through a symbol-keyed hook on the app (HEALTH_DRAIN, not public API) beforeserver.shutdown()/server.stop(false).close(), so it never reports draining.healthis on,/__live__and/__ready__join the boot check CARD-21 introduced (src/http/reserved-paths.ts), for local and mesh-spliced routes. With health off they are ordinary paths.createAppthrows on anyhealthother thantrue,falseor{ drainDelayMs?: number }. That includes unknown keys such aschecks, a negative or non-finite delay, anddrainDelayMs + teardownTimeoutMs > shutdownTimeoutMs.App.close(). README bullet.CHANGELOGunder### Added.Choices the card left open: please confirm
app.fetchbefore any boot starts the boot without waiting for it. Without this, on the edge or under a bareDeno.serve(app.fetch), an orchestrator that waits for ready before sending traffic would seebootingforever, because only a real request would boot the app. The rejection is swallowed only on the probe path; the boot memo keeps it, so real requests still fail with it./__ready__at503 booting. The card has no failed state, and I didn't invent one.teardownTimeoutMsis carved out. AdrainDelayMsthat can't fit throws atcreateApp, the wayteardownTimeoutMs > shutdownTimeoutMsalready does. The card only says "invalid health throws", so this bound is my addition./__ready__/(trailing slash) goes to the route table as usual. A query string is ignored.serveDeno/serveBunthe app boots before it binds, sobootingis only observable throughapp.fetch(T1). Both runtimes run T5 and see ok and draining. T2 and T3 run through shared code on Node.stop(false)and Deno'sshutdown()behaviour after the window is unchanged; D14's runtime limits apply.Test evidence (local, on develop with #134 and #135)
test/health.test.ts:503 drainingduringclose()while/slowcompletes200. WithdrainDelayMs: 0the same test getsECONNRESET, which is D14's rationale, checked by hand.maxConcurrentRequests: 1saturated: probes200, others503), T7 (POST405withAllow; HEAD with no body)@Get('/__live__')boot error, exact message),/__ready__HTTP and WS with health on and off, teapot route at/__ready__logRequests: no log line,bus.emitnever called, a plugin step never runs, with a control request)T5 runs in
test/deno/shutdown.test.tsandtest/bun/shutdown.test.ts. T10 runs intest/edge/run.ts: live 200, ready booting then ok with only probes reaching the isolate.Docs follow-up (CARD-12)
reference/createapp.md: thehealthoption: shape, states and bodies, 405,cache-control,drainDelayMsand its budget rule, the probe-starts-boot behaviour. Add/__live__and/__ready__to the reserved-paths list started for CARD-21.drainDelayMsversus a platformpreStopsleep (PRD open question), why Node needs the window (idle keep-alive sockets close at once), and Deno/Bunclose()behaviour.draining, and booting is per isolate.Owner decisions (2026-10-23): probe-triggered boot,
503 bootingon failed boot, and the drain-vs-shutdown-timeout check are accepted. Not merging yet: implementation review first.f7e26e4dbbtoba57568a84Implementation review done on 2026-10-23: a Codex review of all 12 sprint PRs, with each finding verified. The P1s in #142 and the P3 in #149 are fixed. The owner (Chrnx) authorized merging in order, each one rebased on develop with CI green. This supersedes the earlier "not merging yet" note.
createApp({ health: true }) serves GET/HEAD /__live__ and /__ready__. Ready reports booting until boot() resolves, ok or degraded (from app.degraded()) after that, and draining from the moment close() starts. Probes are answered by the adapters, ahead of the request gate and of handle(): Node in serve() (src/http/server.ts), the Fetch path in app.fetch before it awaits the boot. Otherwise ready could never say booting. Being ahead of the gate means maxConcurrentRequests never sheds a probe (D14). Being ahead of handle() means no step, provider, plugin or onError runs, and no lifecycle event is emitted, so logRequests and metrics never see a probe. Security headers still apply, plus cache-control: no-store. Other methods get 405 with Allow: GET, HEAD. A probe through app.fetch before any boot starts the boot without awaiting it. On the edge, or under a bare Deno.serve(app.fetch), nothing else may boot the app, and an orchestrator that waits for ready before sending traffic would wait forever. health: { drainDelayMs } (D14) marks the app draining and keeps the listener open for that long before connections drain. Without it, Node closes idle keep-alive sockets at once, and a probe sees a reset rather than the 503. The window is spent out of the close budget. serveDeno and serveBun start the same window, through a symbol-keyed hook on the app, before server.shutdown() / server.stop(false). workerd has no close(), so it never reports draining. While health is on, /__live__ and /__ready__ join the reserved-path boot check that CARD-21 introduced, for local and mesh-spliced routes. Invalid health values throw at createApp. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>ba57568a84tof0530b15bb