Skip to content

fix(openclaw): add SQLite resilience for OSS mode initialization#4337

Merged
whysosaket merged 2 commits intomainfrom
fix/openclaw-sqlite-resilience
Mar 16, 2026
Merged

fix(openclaw): add SQLite resilience for OSS mode initialization#4337
whysosaket merged 2 commits intomainfrom
fix/openclaw-sqlite-resilience

Conversation

@utkarsh240799
Copy link
Copy Markdown
Contributor

@utkarsh240799 utkarsh240799 commented Mar 14, 2026

Summary

  • Fix initPromise poisoning in both PlatformProvider and OSSProvider — a failed _init() permanently cached the rejected promise, making the provider broken with no retry possible. Now clears the promise on failure so subsequent calls retry.
  • Add disableHistory passthrough — exposes oss.disableHistory in the plugin config so users can explicitly opt out of SQLite history storage (the underlying mem0ai/oss SDK already supports this via DummyHistoryManager).
  • Graceful SQLite fallback — wraps new Memory(config) in a try-catch; if construction fails and history wasn't already disabled, automatically retries with disableHistory: true and logs a warning. This auto-recovers from native binding failures (jiti resolver regression in OpenClaw 2026.3.x) without losing core memory functionality.

Addresses the class of failures reported in openclaw/openclaw#31676, openclaw/openclaw#36377, and #4172.

Configuration

Users hitting SQLite binding issues can now explicitly disable history:

{
  "mode": "open-source",
  "oss": {
    "disableHistory": true,
    "vectorStore": { "provider": "qdrant", "config": {} }
  }
}

Or rely on the automatic fallback (no config change needed).

Tests

10 new tests added in openclaw/sqlite-resilience.test.ts (all passing):

Config passthrough (4 tests)

  • disableHistory: true survives resolveEnvVarsDeep config parsing
  • disableHistory: false is preserved, not coerced
  • Field is undefined when omitted from config
  • oss sub-object accepts disableHistory without unknown-key rejection

OSSProvider passthrough (2 tests)

  • disableHistory: true reaches the Memory constructor when configured
  • disableHistory is absent from Memory config when user doesn't set it

initPromise retry (2 tests)

  • OSSProvider: after a transient failure (e.g. SQLITE_CANTOPEN), initPromise is cleared and the next call retries successfully instead of returning the cached rejection
  • PlatformProvider: same fix verified — network timeout on first init allows retry on second call

Graceful SQLite fallback (2 tests)

  • When Memory() throws a binding error, automatically retries with disableHistory: true and logs a console.warn; provider becomes functional
  • When disableHistory is already true and init still fails (e.g. vector store issue), throws immediately — no infinite retry loop

Test plan

  • All 24 existing unit tests pass
  • All 10 new resilience tests pass (34 total)

utkarsh240799 and others added 2 commits March 15, 2026 00:48
Fix initPromise poisoning in both PlatformProvider and OSSProvider where
a failed init permanently cached the rejected promise, preventing retries.
Add disableHistory passthrough so users can opt out of SQLite history
storage. Add graceful fallback that auto-retries with history disabled
when Memory construction fails (e.g. native binding resolution under jiti).

Fixes #4172

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…vider for testability

Add 10 tests covering disableHistory config passthrough, initPromise
retry after failure, graceful SQLite fallback, and PlatformProvider
retry. Export mem0ConfigSchema and createProvider for test access.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@whysosaket whysosaket merged commit bfe730a into main Mar 16, 2026
3 checks passed
jamebobob pushed a commit to jamebobob/mem0-vigil-recall that referenced this pull request Mar 29, 2026
…0ai#4337)

Co-authored-by: utkarsh240799 <utkarsh240799@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants