claude-flow icon indicating copy to clipboard operation
claude-flow copied to clipboard

Bug Report: BetterSqlite3 Constructor Error in v2.7.15

Open thesoulpole opened this issue 2 months ago â€ĸ 0 comments

Bug Report: BetterSqlite3 Constructor Error in v2.7.14/v2.7.15. [wygenerowny przez Claude'a)

Summary

Memory commands fail with TypeError: BetterSqlite3 is not a constructor in the latest alpha versions (2.7.14, 2.7.15) when attempting to use ReasoningBank memory storage.

Environment

  • Package: claude-flow@alpha
  • Version Tested: 2.7.14, 2.7.15
  • Installation Method: npm install -g claude-flow@alpha
  • OS: macOS 26.0.1 (Build 25A362)
  • Architecture: arm64 (Apple Silicon)
  • Node.js: v24.6.0
  • npm: 11.6.0

Steps to Reproduce

  1. Install claude-flow alpha version:
npm install -g claude-flow@alpha
  1. Initialize a project:
claude-flow init --force
  1. Attempt to store a memory:
claude-flow memory store mykey "myvalue"

Expected Behavior

Memory should be stored successfully in the ReasoningBank SQLite database.

Actual Behavior

Command fails with the following error:

â„šī¸  🧠 Using ReasoningBank mode...
[ReasoningBank] Initializing...
[ReasoningBank] Enabled: false
[ReasoningBank] Database: .swarm/memory.db
[ReasoningBank] Embeddings: claude
[ReasoningBank] Retrieval k: 3
[ReasoningBank] Migration error: TypeError: BetterSqlite3 is not a constructor
    at Module.runMigrations (file:///opt/homebrew/lib/node_modules/claude-flow/node_modules/agentic-flow/dist/reasoningbank/db/queries.js:26:16)
    at Module.initialize (file:///opt/homebrew/lib/node_modules/claude-flow/node_modules/agentic-flow/dist/reasoningbank/index.js:46:18)
    at file:///opt/homebrew/lib/node_modules/claude-flow/src/reasoningbank/reasoningbank-adapter.js:39:27
    at ensureInitialized (file:///opt/homebrew/lib/node_modules/claude-flow/src/reasoningbank/reasoningbank-adapter.js:47:5)
    at storeMemory (file:///opt/homebrew/lib/node_modules/claude-flow/src/reasoningbank/reasoningbank-adapter.js:71:9)
    at handleReasoningBankStore (file:///opt/homebrew/lib/node_modules/claude-flow/src/cli/simple-commands/memory.js:596:28)
    at handleReasoningBankCommand (file:///opt/homebrew/lib/node_modules/claude-flow/src/cli/simple-commands/memory.js:539:15)
    at async memoryCommand (file:///opt/homebrew/lib/node_modules/claude-flow/src/cli/simple-commands/memory.js:53:12)
[ReasoningBank] Backend initialization failed: Error: ReasoningBank initialization failed: could not run migrations
❌ Failed to store: Failed to initialize ReasoningBank: ReasoningBank initialization failed: could not run migrations

Root Cause Analysis

The issue appears to be in the agentic-flow dependency package. The better-sqlite3 module is not being properly imported or constructed within the ReasoningBank initialization code.

Dependency Versions Found

[email protected]
├── [email protected]
│   └── [email protected]
├── [email protected]
└── [email protected]
    └── [email protected]

Multiple versions of better-sqlite3 are present (11.10.0 and 12.4.1), which may be causing module resolution conflicts.

Attempted Fixes (All Failed)

  1. Rebuilding better-sqlite3:
cd /opt/homebrew/lib/node_modules/claude-flow
npm rebuild better-sqlite3

Result: Build succeeded but error persisted

  1. Rebuilding agentic-flow dependencies:
cd /opt/homebrew/lib/node_modules/claude-flow/node_modules/agentic-flow
npm rebuild

Result: Build succeeded but error persisted

  1. Using --no-reasoningbank flag:
claude-flow memory store mykey "myvalue" --no-reasoningbank

Result: Flag was ignored, same error occurred

Additional Context

  • The rapid version releases (2.7.4 through 2.7.15 in less than 24 hours) suggest this may be a regression introduced during recent development
  • Version 2.7.4 was announced but versions 2.7.5-2.7.15 were published shortly after
  • The init command partially works but also shows the same ReasoningBank error during initialization
  • The error specifically occurs in agentic-flow/dist/reasoningbank/db/queries.js:26:16

Workaround

Users may need to downgrade to v2.7.12 (latest stable non-alpha) until this is resolved:

npm uninstall -g claude-flow
npm install -g [email protected]

Impact

  • Severity: High - Memory storage functionality is completely broken
  • Affected Commands: All memory-related commands (memory store, memory query, memory list, etc.)
  • Affected Systems: At least macOS arm64, possibly other platforms

Related Files

  • /opt/homebrew/lib/node_modules/claude-flow/node_modules/agentic-flow/dist/reasoningbank/db/queries.js
  • /opt/homebrew/lib/node_modules/claude-flow/src/reasoningbank/reasoningbank-adapter.js
  • /opt/homebrew/lib/node_modules/claude-flow/src/cli/simple-commands/memory.js

Suggested Fix

The agentic-flow package needs to properly import and instantiate better-sqlite3. This likely requires:

  1. Ensuring consistent better-sqlite3 versions across all dependencies
  2. Verifying the import statement in agentic-flow/dist/reasoningbank/db/queries.js
  3. Potentially updating to use ES module imports correctly for native modules

Reporter: User via Claude Desktop Commander Date: October 25, 2025 GitHub Issue URL: https://github.com/ruvnet/claude-flow/issues

thesoulpole avatar Oct 25 '25 19:10 thesoulpole