Repository navigation
Conversation
… stale When Node.js is upgraded without rebuilding native deps, better-sqlite3 throws a NODE_MODULE_VERSION mismatch that createDatabase surfaces only as a generic "Failed to create database". Detect this specific case and tell the user to rebuild or reinstall the native module. Closes #562 Co-Authored-By: Claude Opus 4.6 <[email protected]>
🦋 Changeset detectedLatest commit: 23d54cc The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/blocks
@emdash-cms/cloudflare
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
ascorbic
enabled auto-merge (squash)
April 15, 2026 20:41
Merged
0aveRyan
pushed a commit
to 0aveRyan/emdash
that referenced
this pull request
Apr 27, 2026
… stale (emdash-cms#582) When Node.js is upgraded without rebuilding native deps, better-sqlite3 throws a NODE_MODULE_VERSION mismatch that createDatabase surfaces only as a generic "Failed to create database". Detect this specific case and tell the user to rebuild or reinstall the native module. Closes emdash-cms#562 Co-authored-by: Claude Opus 4.6 <[email protected]> Co-authored-by: Matt Kane <[email protected]>
10 of 18 tasks
ascorbic
added a commit
that referenced
this pull request
Aug 27, 2026
…ter (#2106) * fix(core): replace better-sqlite3 with node:sqlite in the sqlite adapter better-sqlite3's natively compiled binary breaks deployments the moment the environment and the binary disagree: NODE_MODULE_VERSION mismatches after Node upgrades (#562, #582) and glibc version errors on shared hosting where the OS is older than the build machine (#1833). Using the Node.js built-in driver removes the native dependency entirely. The sqlite() adapter and the CLI's createDatabase() now open databases through node:sqlite's DatabaseSync, wrapped in a small better-sqlite3- compatible shim (node-sqlite-compat.ts) so Kysely's built-in SqliteDialect is unchanged. Statement .reader is derived from StatementSync.columns(), preserving INSERT ... RETURNING semantics. - better-sqlite3 moves to a devDependency (tests still use it directly) - drops the NODE_MODULE_VERSION rebuild hint (no native binary anymore) - removes better-sqlite3/bindings/file-uri-to-path from bundler externals - emdash package now declares engines node >=22.15 (unflagged node:sqlite + StatementSync.columns()) Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QSivQavm4D4nK86DgJBJCX * Address review feedback on the node:sqlite adapter Test harness: packages/core/tests/utils/test-db.ts created its SQLite databases with better-sqlite3, so the suite never exercised the driver the package actually ships. It now goes through openNodeSqliteDatabase. The three tests that use better-sqlite3 directly keep it as a devDep. Parameter binding: node:sqlite binds a narrower set of JS types than better-sqlite3, and differs in both directions, so toBindings now maps instead of casting. - undefined -> NULL. better-sqlite3 accepted it, node:sqlite throws. Reachable from ordinary Kysely usage (`.where(col, "=", undefined)` from an unset optional filter), so this was a real regression. - Date -> actionable TypeError. better-sqlite3 threw; node:sqlite silently binds NULL, turning a loud programming error into silent data loss. - boolean -> 0/1. Note the review's premise was inverted: better-sqlite3 12.8.0 also rejects booleans ("SQLite3 can only bind numbers, strings, bigints, buffers, and null"), so this is not a regression from this PR. It is a pre-existing bug — the plugin storage query API advertises `boolean` in WhereValue (plugins/types.ts) but threw at bind time on either driver — and mapping here fixes it. Pragmas: journal_mode=WAL, busy_timeout=5000 and foreign_keys=ON move into openNodeSqliteDatabase, the single place the package opens SQLite. Previously only the CLI path set them, so sites on the runtime sqlite() adapter silently got none of them. Lockfile: regenerated with the repo's pinned pnpm (11.9.0 via corepack) rather than the pnpm 9 that produced the original diff. pnpm 10+ reads overrides/patchedDependencies from pnpm-workspace.yaml, which pnpm 9 ignores, which is why they were dropped from the lockfile — taking the "@ungap/structured-clone" CWE-502 security pin and the @sigstore/core patch with them. The lockfile diff against main is now only the better-sqlite3 importer moves. Also drops better-sqlite3 from the 9 templates/demos/fixtures that listed it as a runtime dependency but never imported it, so new sites no longer pull the native binary. Verified: 4760 tests pass (the one failure, virtual-modules.test.ts, fails identically on the unmodified PR tip — a macOS /var symlink issue). Query-count harness matches its snapshots exactly, and WAL is confirmed applied on the built fixture's data.db. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01JSxrM3SUUGvrr9dzTQrbmF * fix(core): replace better-sqlite3 with node:sqlite Rebuilds and completes the approach proposed in #2106 against current main, with strict binding compatibility, preserved SQLite connection settings, static-prerender coverage, and updated packaging and documentation.\n\nCo-authored-by: gruntlord5 <[email protected]> --------- Co-authored-by: Claude Fable 5 <[email protected]> Co-authored-by: Matt Kane <[email protected]>
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.
What does this PR do?
When Node.js is upgraded (or
node_moduleswas built with a different Node version),better-sqlite3fails to load with aNODE_MODULE_VERSIONmismatch. Today,createDatabasecatches this and surfaces a genericFailed to create database— the real cause is only visible if the user digs into thecause.This PR detects the
NODE_MODULE_VERSIONstring in the underlying error and throws anEmDashDatabaseErrorwhose message tells the user exactly what to do: rebuild the native module withpnpm rebuild better-sqlite3(or reinstall deps).The helper is exported and covered by unit tests.
Closes #562
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runpnpm locale:extracthas been run (if applicable)AI-generated code disclosure
Screenshots / test output