-
Notifications
You must be signed in to change notification settings - Fork 829
Description
Summary
t3@alpha can crash during startup/install on Node versions that currently satisfy the package's engines.node range.
The failure looks like this:
(node:52234) ExperimentalWarning: SQLite is an experimental feature and might change at any time
[23:44:38.432] ERROR (#10): Error: Failed to execute statement
{ [cause]: TypeError: statement.columns is not a function
at hasRows (file:///.../node_modules/t3/dist/NodeSqliteClient-....mjs:44:28)
Repro
Run:
npx t3@alpha
on a Node version that is currently allowed by package.json, but does not support StatementSync.columns() in node:sqlite.
The current published package declares:
"engines": {
"node": "^22.13 || ^23.4 || >=24.10"
}Root cause
The Node SQLite client calls statement.columns() in src/persistence/NodeSqliteClient.ts to determine whether a prepared statement returns rows.
But StatementSync.columns() in node:sqlite was only added in:
- Node 22.16.0
- Node 23.11.0
So the current engine range admits unsupported Node versions such as:
- 22.13.x through 22.15.x
- 23.4.x through 23.10.x
That means the package accepts runtimes it cannot actually execute on, and users get a low-level runtime crash instead of a clear upgrade error.
Why this matters
This is especially confusing because the package appears to support those Node versions based on engines, but fails only after startup reaches persistence initialization.
Suggested fix
There are two parts to fixing this cleanly:
- Tighten the engine range in package.json to match the first Node versions that actually support the required API:
"engines": {
"node": "^22.16 || ^23.11 || >=24.10"
}- Add a runtime preflight in the central SQLite loader (
src/persistence/Layers/Sqlite.ts) before loading the Node SQLite client, so unsupported runtimes fail immediately with a clear message.
Suggested behavior:
- detect Node runtime version
- if running on an unsupported version, throw an error like:
Unsupported Node.js version for t3 SQLite support. This build requires node:sqlite StatementSync.columns(), available in Node >=22.16, >=23.11, or >=24.10.
Optional defense-in-depth
It would also be useful to keep a small defensive assertion inside src/persistence/NodeSqliteClient.ts so any unexpected API mismatch still fails with the same actionable message instead of:
TypeError: statement.columns is not a function
Expected behavior
On unsupported Node versions, t3 should fail fast with a clear upgrade message.
On supported Node versions, startup should proceed normally.
Prompt
Fix the Node runtime compatibility bug in the t3 repo.
Problem:
- The package uses `StatementSync.columns()` from `node:sqlite`.
- That API only exists in Node `22.16.0+`, `23.11.0+`, and supported `24.x`.
- But `package.json` currently allows `^22.13 || ^23.4 || >=24.10`, so users on allowed versions can still hit `TypeError: statement.columns is not a function`.
Make these changes:
1. Update `package.json` `engines.node` to `^22.16 || ^23.11 || >=24.10`.
2. Add a Node-only runtime preflight in the central SQLite loader (`src/persistence/Layers/Sqlite.ts`) that rejects unsupported Node versions before loading `NodeSqliteClient`, with a clear upgrade message.
3. Add a small defensive assertion in `src/persistence/NodeSqliteClient.ts` so unexpected API mismatches fail with the same actionable error instead of a raw `TypeError`.
4. Add or update tests covering the unsupported-runtime error path if there is an existing startup/persistence test area.
5. Keep the change minimal and focused.
6. Run `bun lint` and `bun typecheck`.
Reference:
https://nodejs.org/api/sqlite.html#statementcolumns