fix: tighten node engine range for node:sqlite compat (#206) (#1096)

Co-authored-by: Julius Marminge <[email protected]>
This commit is contained in:
Etan HeymanandJulius Marminge authored and GitHub committed 2026-03-14 19:22:56 -07:00
1 parent 2bb71f41c3
commit 6d76865e74
2 files changed
+25 -1

No files matched your search

+1 -1
View File
@@ -44,6 +44,6 @@
"vitest": "catalog:"
},
"engines": {
"node": "^22.13 || ^23.4 || >=24.10"
"node": "^22.16 || ^23.11 || >=24.10"
}
}
@@ -50,11 +50,35 @@ export interface SqliteMemoryClientConfig extends Omit<
"filename" | "readonly"
> {}
/**
* Verify that the current Node.js version includes the `node:sqlite` APIs
* used by `NodeSqliteClient` — specifically `StatementSync.columns()` (added
* in Node 22.16.0 / 23.11.0).
*
* @see https://github.com/nodejs/node/pull/57490
*/
const checkNodeSqliteCompat = () => {
const parts = process.versions.node.split(".").map(Number);
const major = parts[0] ?? 0;
const minor = parts[1] ?? 0;
const supported = (major === 22 && minor >= 16) || (major === 23 && minor >= 11) || major >= 24;
if (!supported) {
return Effect.die(
`Node.js ${process.versions.node} is missing required node:sqlite APIs ` +
`(StatementSync.columns). Upgrade to Node.js >=22.16, >=23.11, or >=24.`,
);
}
return Effect.void;
};
const makeWithDatabase = (
options: SqliteClientConfig,
openDatabase: () => DatabaseSync,
): Effect.Effect<Client.SqlClient, never, Scope.Scope | Reactivity.Reactivity> =>
Effect.gen(function* () {
yield* checkNodeSqliteCompat();
const compiler = Statement.makeCompilerSqlite(options.transformQueryNames);
const transformRows = options.transformResultNames
? Statement.defaultTransforms(options.transformResultNames).array