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 #225
A database that fails to open or upgrade no longer kills the server. It still listens, and /healthz answers 503 naming the step that failed. What changed src/db.ts: openDb now runs migration, seed and sample refresh as named steps.
stopped closed without shipping deploy 1a76f84
A database that fails to open or upgrade no longer kills the server. It still listens, and /healthz answers 503 naming the step that failed.
What changed
src/db.ts:openDbnow runs migration, seed and sample refresh as named steps. A failure throws anOpenErrorcarrying the step name and SQLite's own message, and the connection is closed first. The migrations themselves are untouched, so #214's ground is clear.src/server.ts:serve()catches that failure and logs one line:<title>: database cannot be opened at boot, step "migration" failed: <message>. It then starts a minimal server on the same port.
- /healthz answers 503 as plain text with the step and message, no stack.
- Every other path answers 503 with a short page saying the app cannot open its records.
- Both carry the security headers from src/http.ts, plus cache-control: no-store and retry-after: 60.
- Nothing in that state writes to the database. The migration runs in a transaction, so a failure rolls back. A failed seed or sample refresh is left as SQLite leaves it, not repaired.
src/health.test.ts: a new test bootsserve()on a directory whoseschema_versionrecords version 1 with no tables. It asserts that the server listens,/healthzis 503 and namesmigration, and/is 503 with the headers. It also checks the log line and thatschema_versionis unchanged afterwards.
Checked
bun testonsrc/health.test.ts,src/db.test.ts,src/server.test.tsandsrc/upgrade.test.ts: 121 pass. I did not run the full suite.- I did not run the new test against main to watch it fail. On main the boot throws before listening, so there is nothing for it to connect to.
bun x tsc --noEmitprinted tsc's help text and checked nothing, because the repo has notsconfig.json.- I did not run
scripts/gate.ts,scripts/fast.tsorscripts/design-lint.ts: none exists in this clone, andsrc/web/is untouched.
Left alone
/healthzechoes SQLite's message verbatim, as the issue asked. Those messages name tables and columns but not file paths.- I did not add retry or self-repair. That is #214.
- The contract is unchanged, so no cell was loosened.
To try it, point serve() at a data directory whose app.db has a recorded schema version but a table missing, then curl -i /healthz and /.
Declined: I did not change the code, so nothing new is pushed. The preview failure is not caused by this pull, and the only fix is #214, which this issue told me to stay out of. Run log: https://forge.open-platform.sh/trevato/deal-clock/runs/01m6zcfqx91159b9na60ydjfnb
A database that fails to open or upgrade no longer kills the server. It still listens, and
/healthzanswers 503 naming the step that failed.What changed
src/db.ts:openDbnow runs migration, seed and sample refresh as named steps. A failure throws anOpenErrorcarrying the step name and SQLite's own message, and the connection is closed first. The migrations themselves are untouched, so #214's ground is clear.src/server.ts:serve()catches that failure and logs one line:<title>: database cannot be opened at boot, step "migration" failed: <message>. It then starts a minimal server on the same port.-
/healthzanswers 503 as plain text with the step and message, no stack. - Every other path answers 503 with a short page saying the app cannot open its records. - Both carry the security headers fromsrc/http.ts, pluscache-control: no-storeandretry-after: 60. - Nothing in that state writes to the database. The migration runs in a transaction, so a failure rolls back. A failed seed or sample refresh is left as SQLite leaves it, not repaired.src/health.test.ts: a new test bootsserve()on a directory whoseschema_versionrecords version 1 with no tables. It asserts that the server listens,/healthzis 503 and namesmigration, and/is 503 with the headers. It also checks the log line and thatschema_versionis unchanged afterwards.Checked
bun testonsrc/health.test.ts,src/db.test.ts,src/server.test.tsandsrc/upgrade.test.ts: 121 pass. I did not run the full suite.bun x tsc --noEmitprinted tsc's help text and checked nothing, because the repo has notsconfig.json.scripts/gate.ts,scripts/fast.tsorscripts/design-lint.ts: none exists in this clone, andsrc/web/is untouched.Left alone
/healthzechoes SQLite's message verbatim, as the issue asked. Those messages name tables and columns but not file paths.To try it, point
serve()at a data directory whoseapp.dbhas a recorded schema version but a table missing, thencurl -i /healthzand/.Closes #222