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
Commit f2063f3
Browse filesBrowse the repository at this point in the historyBrowse files
authored
fix(cli): extend better-sqlite3 → wasm SQLite auto-fallback to the persistent-file / --artifact dev path (#2229) (#2234)
The native-better-sqlite3 → wasm SQLite → in-memory step-down previously only
guarded the zero-config `:memory:` dev branch of `serve`. A normal
`objectstack dev` run never reached it: `dev` injects a persistent `file:` DB so
AI-authored data survives restarts, and `--artifact` boots resolve sqlite
through the datasource factory — both constructed `better-sqlite3` directly with
no probe and no fallback. better-sqlite3 loads its native addon lazily (first
query), so an ABI mismatch was invisible at boot and surfaced later as a runtime
`Find operation failed`.
Hoist the probe-by-connect + step-down into a shared `resolveSqliteDriver`
helper (@objectstack/service-datasource) and apply it to both previously
unguarded sqlite construction sites: the explicit `sqlite`/`file:` branch in
serve.ts and the sqlite branch of the default datasource driver factory. The
helper forces the native load with `connect()` + `SELECT 1` and, in dev only,
steps down to wasm SQLite (real SQL + on-disk persistence — the same `file:`
keeps working) then to in-memory as a last resort, emitting the existing
`⚠ native better-sqlite3 unavailable …` warning. In production the native driver
is returned unprobed so a load failure surfaces loudly (fail-closed) instead of
silently degrading. Dev is plumbed through standalone-stack so the --artifact
boot enables the fallback explicitly (NODE_ENV fallback otherwise).
Adds a co-located unit test simulating a NODE_MODULE_VERSION load failure
(asserts wasm fallback + warning, in-memory last resort, and prod fail-closed).
Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
0 commit comments