| @objectstack/driver-sqlite-wasm | patch |
|---|
Harden the wasm SQLite driver (the dev fallback used when native better-sqlite3 has an ABI mismatch) against three failure modes that spammed pnpm dev:
- Atomic flushes. The database was persisted with a plain
writeFilethat truncates-then-streams in place, so a process killed mid-write (a dev-server restart, Ctrl-C, or crash — likely underon-write, where every dispatcher tick flushes) left a torn file that sql.js rejected on the next boot withdatabase disk image is malformed. Flushes now write to a sibling temp file,fsync, and atomicallyrename()over the target, so a reader always sees a complete image. - Corruption self-heal. When an on-disk image is already corrupt, the driver now detects it at open (via
PRAGMA quick_check), quarantines the bad file to<db>.corrupt-<timestamp>, and boots on a fresh database — instead of failing every query forever with no path to recovery. undefinedbindings. A rawundefinedbinding made sql.jsthrowa plain string (Wrong API use : tried to bind a value of an unknown type (undefined).), which aborted the write and logged as a garbled char-indexed object.undefinedis now coerced to SQLNULL, matching the driver'suseNullAsDefaultsemantics and the native better-sqlite3 path.