fix: replace sqlite3 with better-sqlite3 to fix native binding resolution#4123
Closed
worldofgeese wants to merge 1 commit intomem0ai:mainfrom
Closed
fix: replace sqlite3 with better-sqlite3 to fix native binding resolution#4123worldofgeese wants to merge 1 commit intomem0ai:mainfrom
worldofgeese wants to merge 1 commit intomem0ai:mainfrom
Conversation
…tion Replace sqlite3 with better-sqlite3 in SQLiteManager.ts to fix the native binding resolution issue in OpenClaw plugin (mem0ai#4107). better-sqlite3: - Ships prebuilt binaries via prebuild-install (no compile step) - Uses different native loading mechanism that works with jiti bundler - Is synchronous (simpler API, often faster for WAL pattern) - Has broader platform coverage (x64, ARM64, musl/glibc) Changes: - Rewrite SQLiteManager to use better-sqlite3 synchronous API - Update peerDependencies: sqlite3 -> better-sqlite3 ^11.9.1 - Update onlyBuiltDependencies: sqlite3 -> better-sqlite3 - Remove @types/sqlite3 (better-sqlite3 ships its own types) Fixes mem0ai#4107 Fixes mem0ai#4050 (same root cause)
|
Tao Hansen seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
7 tasks
Contributor
|
The issue was resolved in #4270 |
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.
Summary
Replace
sqlite3withbetter-sqlite3to fix the native binding resolution issue that occurs when the @mem0/openclaw-mem0 plugin is loaded through jiti (JIT TypeScript/ESM loader).Problem
The
sqlite3package uses thebindingsmodule to locate its native.nodeaddon at runtime by walking up from__dirnameof the caller. When OpenClaw loads the mem0 plugin through jiti, the caller__dirnameresolves to jiti's own location inside the pnpm store (/app/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/), but the actualnode_sqlite3.nodebinary lives in the plugin's extension directory (/home/node/.openclaw/extensions/openclaw-mem0/node_modules/sqlite3/build/Release/node_sqlite3.node). The bindings module never searches there.This causes the error:
Solution
Replace
sqlite3withbetter-sqlite3which:prebuild-install(no compile step needed)bindingsmodule's path walkingChanges
SQLiteManager.ts
better-sqlite3's synchronous APIrun,all) since better-sqlite3 is syncinit()- no longer needs async error handlingaddHistory,getHistory,resetnow use prepared statementspackage.json
sqlite3: 5.1.7→better-sqlite3: ^11.9.1sqlite3→better-sqlite3@types/sqlite3from peerDependencies (better-sqlite3 ships its own types)Migration
Users will need to:
npm uninstall sqlite3orpnpm remove sqlite3npm install better-sqlite3orpnpm add better-sqlite3Testing
Fixes
Related