Found reviewing #1021 (sirtimid/crank-rollback-integrity).
What
wasm.ts reaches the autocommit binding through an unchecked cast:
sqlite3.capi as Sqlite3Static['capi'] & AutocommitCapi
@sqlite.org/sqlite-wasm's index.d.ts declares CAPI as a generated member list with no index signature and no sqlite3_get_autocommit. The binding does exist in the installed build — but nothing verifies that.
If it is ever absent or renamed, getAutocommit is undefined and every read of inTransaction throws TypeError — from inside beginIfNeeded, commitIfNeeded and rollbackIfNeeded, i.e. the exact machinery #1021 exists to harden. Browser-only, at runtime, with no startup signal.
This is the one place in that diff where an as cast stands in for an unverified assumption about a foreign module, and it is load-bearing: replacing the cached _inTx with a live sqlite3_get_autocommit read is the headline fix of the kernel-store half.
Suggested fix
One line at init turns a scattered runtime TypeError into a clear startup failure:
typeof getAutocommit === 'function' ||
Fail`sqlite3 capi lacks sqlite3_get_autocommit`;
Found reviewing #1021 (
sirtimid/crank-rollback-integrity).What
wasm.tsreaches the autocommit binding through an unchecked cast:@sqlite.org/sqlite-wasm'sindex.d.tsdeclaresCAPIas a generated member list with no index signature and nosqlite3_get_autocommit. The binding does exist in the installed build — but nothing verifies that.If it is ever absent or renamed,
getAutocommitisundefinedand every read ofinTransactionthrowsTypeError— from insidebeginIfNeeded,commitIfNeededandrollbackIfNeeded, i.e. the exact machinery #1021 exists to harden. Browser-only, at runtime, with no startup signal.This is the one place in that diff where an
ascast stands in for an unverified assumption about a foreign module, and it is load-bearing: replacing the cached_inTxwith a livesqlite3_get_autocommitread is the headline fix of the kernel-store half.Suggested fix
One line at init turns a scattered runtime
TypeErrorinto a clear startup failure: