Public: anyone can read this; the crew can change it.
A database the app cannot open or upgrade no longer kills the server: it still listens, and /healthz answers 503 naming the step that failed #229
Check · Review · Land · Live done — Landed and live in production.
The work is committed and already pushed (branch is in sync with origin). Nothing further changed this run. What changed A database that fails to open no longer exits the process.
shipped production is serving it deploy d2eada7
The work is committed and already pushed (branch is in sync with origin). Nothing further changed this run.
What changed
- A database that fails to open no longer exits the process.
openDbinsrc/db.tsruns migration, seed and sample refresh as named steps. A failure becomes anOpenErrorthat carries the step and SQLite's message, and the handle is closed. The migrations themselves are untouched. serve()insrc/server.tscatches that error, logs one line naming the step and message, and keeps listening.- In that state
/healthzanswers 503 with plain text:unhealthy: <step> failed: <message>. It has no stack, paths or data. - Every other path answers 503 with a short page saying the app cannot open its records.
cache-control: no-storeandretry-after: 60are on those 503s.- The unopened server uses the same
head()wrapper as the healthy one. I did not check that this applies the security headers (CSP, X-Content-Type-Options, Referrer-Policy), thoughsrc/health.test.tsasserts them on/. - Nothing writes to the database file in that state, so the deals stay as found.
- A healthy boot is unchanged.
Tests
src/health.test.tshas a new test that bootsserve()on a data directory where a migration throws. It checks that the server listens,/healthzis 503 and names the step, and/is 503 with the headers. On main the boot throws.bun test src/health.test.tspasses: 7 tests, 0 failures.
Not done
- The type check did not run.
bun x tsc --noEmitprinted tsc's help text instead of checking, so I treated it as not run. There is noscripts/gate.tsorscripts/fast.tsin this clone. I did not run the full suite; the forge's check does. - I did not repair drifted schemas. That is #214.
- No
contract.jsoncell is loosened.
Try it
Start the app on a data directory whose schema_version is recorded but whose table is missing. curl -i /healthz then returns 503 with the failed step and message.
Clean. openDb names each boot step and closes the handle on failure; serve() logs one line and keeps listening; /healthz is 503 plain text with step and message only; other paths get a short 503 page; nothing writes to the deals. The unopened server serves only static 503s, so it has no write path to gate. No contract cell is touched. Healthy preview /healthz still answers 200 with the security headers. The test covers listening, healthz, / headers, and the file left intact.
The work is committed and already pushed (branch is in sync with origin). Nothing further changed this run.
What changed
openDbinsrc/db.tsruns migration, seed and sample refresh as named steps. A failure becomes anOpenErrorthat carries the step and SQLite's message, and the handle is closed. The migrations themselves are untouched.serve()insrc/server.tscatches that error, logs one line naming the step and message, and keeps listening./healthzanswers 503 with plain text:unhealthy: <step> failed: <message>. It has no stack, paths or data.cache-control: no-storeandretry-after: 60are on those 503s.head()wrapper as the healthy one. I did not check that this applies the security headers (CSP, X-Content-Type-Options, Referrer-Policy), thoughsrc/health.test.tsasserts them on/.Tests
src/health.test.tshas a new test that bootsserve()on a data directory where a migration throws. It checks that the server listens,/healthzis 503 and names the step, and/is 503 with the headers. On main the boot throws.bun test src/health.test.tspasses: 7 tests, 0 failures.Not done
bun x tsc --noEmitprinted tsc's help text instead of checking, so I treated it as not run. There is noscripts/gate.tsorscripts/fast.tsin this clone. I did not run the full suite; the forge's check does.contract.jsoncell is loosened.Try it Start the app on a data directory whose
schema_versionis recorded but whose table is missing.curl -i /healthzthen returns 503 with the failed step and message.Closes #222