Skip to content

fix: quarantine stale sqlite native binding#2049

Draft
RerankerGuo wants to merge 1 commit into
MemTensor:mainfrom
RerankerGuo:fix/quarantine-stale-sqlite-binding
Draft

fix: quarantine stale sqlite native binding#2049
RerankerGuo wants to merge 1 commit into
MemTensor:mainfrom
RerankerGuo:fix/quarantine-stale-sqlite-binding

Conversation

@RerankerGuo

Copy link
Copy Markdown

Description

Related Issue (Required): Fixes #1343

Handles stale better-sqlite3 native bindings left behind after OpenClaw plugin updates.

Postinstall already detects NODE_MODULE_VERSION mismatches and attempts npm rebuild better-sqlite3, but the stale .node file was left in place. On Windows update paths this can leave the old ABI artifact visible to the next startup/rebuild check. This change quarantines the mismatched native binding before running the rebuild, falling back to removal if the rename fails.

The existing native binding validator remains the source of truth for deciding whether the binding is loadable. Other load errors are not quarantined.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Unit Test
  • Test Script Or Test Steps (please provide)
  • Pipeline Automated API Test (please provide)

Commands run:

node - <<'NODE'
const { quarantineNativeBinding, validateNativeBinding } = require('./apps/memos-local-openclaw/scripts/native-binding.cjs');
const mismatch = validateNativeBinding('/tmp/fake.node', () => { throw new Error('NODE_MODULE_VERSION 127 requires 137'); });
if (mismatch.ok || mismatch.reason !== 'node-module-version') throw new Error('mismatch not detected');
const moved = quarantineNativeBinding('/tmp/better_sqlite3.node', { existsSync: () => true, renameSync() {}, unlinkSync() {} }, 123);
if (!moved.ok || moved.reason !== 'renamed' || !moved.quarantinedPath.includes('abi-mismatch-123')) throw new Error('quarantine rename failed');
const removed = quarantineNativeBinding('/tmp/better_sqlite3.node', { existsSync: () => true, renameSync: () => { throw new Error('EPERM'); }, unlinkSync() {} }, 124);
if (!removed.ok || removed.reason !== 'removed') throw new Error('quarantine unlink fallback failed');
console.log('native binding quarantine checks passed');
NODE

Result: native binding quarantine checks passed.

Also attempted:

cd apps/memos-local-openclaw
npm test -- --run tests/postinstall-native-binding.test.ts
npm run build
make format

npm test is blocked because vitest is not installed. npm run build is blocked because tsc is not installed. make format is blocked because poetry is not installed.

Checklist

  • I have performed a self-review of my own code | 我已自行检查了自己的代码
  • I have commented my code in hard-to-understand areas | 我已在难以理解的地方对代码进行了注释
  • I have added tests that prove my fix is effective or that my feature works | 我已添加测试以证明我的修复有效或功能正常
  • I have created related documentation issue/PR in MemOS-Docs (if applicable) | 我已在 MemOS-Docs 中创建了相关的文档 issue/PR(如果适用)
  • I have linked the issue to this PR (if applicable) | 我已将 issue 链接到此 PR(如果适用)
  • I have mentioned the person who will review this PR | 我已提及将审查此 PR 的人

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]better-sqlite3 ABI mismatch after updating memos-local-openclaw-plugin on Windows; manual rebuild required

1 participant