Repository navigation
fix: support better-sqlite3 v13 - #12971
Closed
Ahmad-Mosha wants to merge 1 commit into
Closed
Ahmad-Mosha wants to merge 1 commit into
Ahmad-Mosha wants to merge 1 commit into
Conversation
Widen the better-sqlite3 peer dependency range to ^12.0.0 || ^13.0.0. Only pass `nativeBinding` to better-sqlite3 when it is configured. The platform entrypoints added in v13 (e.g. `better-sqlite3/linux-x64`) throw when the option is present, even as `null`, so using one through the `driver` option failed. The devDependency stays on v12: v13 requires Node-API 10, which Node.js 20 lacks, and CI still tests Node.js 20. Closes typeorm#12961
This was referenced Nov 19, 2026
|
An independent data point for the verification section: in our project's suite, the SQLite storage and TypeORM sqlite-driver tests (683) passed 683/683 on Node 26.13 with |
Collaborator
|
Already bumped up most packages in #13070. You should be able to use |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of change
Closes #12961.
TypeORM's peer range for
better-sqlite3is^12.0.0, so npm refuses to install v13 alongside TypeORM (ERESOLVE). This PR makes four changes.^12.0.0 || ^13.0.0.nativeBinding. It is now passed to better-sqlite3 only when it is configured.nativeBinding: null.better-sqlite3/linux-x64) throw when the key is present at all, so they couldn't be used through thedriveroption.null, and a configured value is still forwarded unchanged.driverwrapper around the real module, so they run on the current devDependency.nativeBindingtest now locates the addon for either version:build/Release/in v12,prebuilds/in v13.drivers/sqlite.mdnow describes v13's Node.js requirement.The devDependency stays on v12. v13 is built against Node-API 10, which Node.js 20 lacks, and it segfaults there.
tests-linuxjob except cockroachdb runs on Node.js 20.data-source.test.tsalways opens a better-sqlite3 connection, so a bump would crash those jobs even for other drivers.typeorm initwould scaffold v13 for Node.js 20 users.This follows the guidance in #11683, and the bump can come with dropping Node.js 20 (#12853). The trade-off is that CI keeps covering v12 only, so v13 was tested locally (below).
Known risk. v13 declares
"node": ">=22", which understates its actual requirement (WiseLibs/better-sqlite3#1514). Node.js 22.13.x satisfies that range but lacks Node-API 10. In a simulated install, npm picked v13 there under the new peer range, and v13 crashes the process when the database is opened. This PR doesn't prevent that; the docs only state the requirement. On Node.js 20, npm still picked v12 because v13'senginesexcludes it. I didn't check pnpm or yarn.Apart from that requirement, I found no differences in the better-sqlite3 APIs the driver uses. One exception: v13 rejects
DataViewparameters, which TypeORM itself never creates.Verification
The full better-sqlite3 suite (CI ormconfig, macOS arm64) passed 3108, failed 0 for:
The v13 runs used a local devDependency bump that is not part of this PR.
The new "not set" test fails when the driver change is reverted.
A
DataSourceusingdriver: require("better-sqlite3/darwin-arm64")fails on master and works with this PR.v13
new Database()segfaults on Node.js 20.20.2 and 22.13.1, and works on 22.14.0, 22.23.2, 24 and 26.11.1. I checked this on macOS and on Linux arm64 in Docker.pnpm install --frozen-lockfilepasses with the lockfile unchanged, and typecheck, ESLint and Prettier pass.Not tested locally:
Pull-Request Checklist
masterbranchCloses #12961tests/**.test.ts)docs/docs/**.md)