openclaw - 💡(How to fix) Fix memory index --force crashes with EMFILE: too many open files, watch across builtin, Ollama, and QMD backends on macOS [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#59101Fetched 2026-04-08 02:28:37
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0

openclaw memory index --force crashes with:

Error: EMFILE: too many open files, watch
    at FSWatcher._handle.onchange (node:internal/fs/watchers:267:21)

This reproduces across multiple memory provider/backend combinations and still happens after rebuilding the memory DB from scratch.

Error Message

Error: EMFILE: too many open files, watch at FSWatcher._handle.onchange (node:internal/fs/watchers:267:21)

Root Cause

openclaw memory index --force crashes with:

Error: EMFILE: too many open files, watch
    at FSWatcher._handle.onchange (node:internal/fs/watchers:267:21)

This reproduces across multiple memory provider/backend combinations and still happens after rebuilding the memory DB from scratch.

Code Example

Error: EMFILE: too many open files, watch
    at FSWatcher._handle.onchange (node:internal/fs/watchers:267:21)

---

{
  "agents": {
    "defaults": {
      "memorySearch": {
        "provider": "local"
      }
    }
  }
}

---

{
  "agents": {
    "defaults": {
      "memorySearch": {
        "provider": "ollama"
      }
    }
  }
}

---

OLLAMA_API_KEY=ollama-local

---

{
  "memory": {
    "backend": "qmd",
    "qmd": {
      "command": "/opt/homebrew/bin/qmd",
      "includeDefaultMemory": true
    }
  }
}

---

files: 0
chunks: 0
dirty: true
scan.totalFiles: 2
issues: []

---

provider: "ollama"
model: "nomic-embed-text"
scan.totalFiles: 2

---

Provider: qmd
Indexed: 0/2 files
Embeddings error: QMD index has 0 vectors

---

Error: EMFILE: too many open files, watch
    at FSWatcher._handle.onchange (node:internal/fs/watchers:267:21)
RAW_BUFFERClick to expand / collapse

Summary

openclaw memory index --force crashes with:

Error: EMFILE: too many open files, watch
    at FSWatcher._handle.onchange (node:internal/fs/watchers:267:21)

This reproduces across multiple memory provider/backend combinations and still happens after rebuilding the memory DB from scratch.

Environment

  • OpenClaw: 2026.3.31 (213a704)
  • OS: macOS
  • Node: v24.14.1
  • Install method: global npm/Homebrew-managed Node install
  • Current memory provider tested:
    • builtin + provider: local
    • builtin + provider: ollama
    • memory.backend = "qmd"

What I tested

1. Original local embeddings path

Configured:

{
  "agents": {
    "defaults": {
      "memorySearch": {
        "provider": "local"
      }
    }
  }
}

Observed:

  • openclaw memory status --json worked
  • openclaw memory index --force crashed with EMFILE: too many open files, watch

2. Clean-room repro

Created an isolated temp profile and workspace with only two tiny markdown files in workspace/memory/.

Observed:

  • memory status --json saw scan.totalFiles = 2
  • memory index --force still crashed with the same EMFILE error

3. Rebuilt memory DB from scratch

Backed up and deleted:

  • ~/.openclaw/memory/main.sqlite
  • ~/.openclaw/memory/main.sqlite.tmp-*

Observed after rebuild:

  • fresh status showed files: 0, chunks: 0, dirty: true, scan.totalFiles: 2
  • memory index --force still crashed with the same EMFILE

4. Switched to Ollama

Installed Ollama and nomic-embed-text, configured:

{
  "agents": {
    "defaults": {
      "memorySearch": {
        "provider": "ollama"
      }
    }
  }
}

Also set:

OLLAMA_API_KEY=ollama-local

Observed:

  • openclaw memory status --json showed:
    • provider: "ollama"
    • model: "nomic-embed-text"
  • openclaw memory index --force still crashed with the same EMFILE

5. Switched to QMD backend

Configured:

{
  "memory": {
    "backend": "qmd",
    "qmd": {
      "command": "/opt/homebrew/bin/qmd",
      "includeDefaultMemory": true
    }
  }
}

Observed:

  • openclaw memory status --deep showed:
    • Provider: qmd
    • Store: ~/.openclaw/agents/main/qmd/xdg-cache/qmd/index.sqlite
    • Indexed: 0/2 files
    • Embeddings error: QMD index has 0 vectors; semantic search is unavailable until embeddings finish
  • openclaw memory index --force still crashed with the same EMFILE
  • before the crash, OpenClaw also logged a QMD collection conflict warning:
    • qmd collection add skipped for memory-alt-main ... A collection already exists for this path and pattern

Important observations

  • This does not appear tied to:
    • node-llama-cpp
    • Ollama
    • the builtin SQLite memory DB
    • one corrupt memory markdown file
  • The same failure happens with:
    • builtin memory + local provider
    • builtin memory + ollama provider
    • QMD backend
  • The same failure also reproduces in a clean temporary OpenClaw state directory with only two small memory files

Current memory files

Only two files under workspace/memory/, both normal markdown and readable.

Related status outputs

Example after DB rebuild:

files: 0
chunks: 0
dirty: true
scan.totalFiles: 2
issues: []

Example with Ollama:

provider: "ollama"
model: "nomic-embed-text"
scan.totalFiles: 2

Example with QMD:

Provider: qmd
Indexed: 0/2 files
Embeddings error: QMD index has 0 vectors

Expected behavior

openclaw memory index --force should rebuild the memory index successfully.

Actual behavior

It crashes consistently with:

Error: EMFILE: too many open files, watch
    at FSWatcher._handle.onchange (node:internal/fs/watchers:267:21)

Notes

This looks like a problem in OpenClaw’s memory indexing/orchestration/watch layer rather than in a specific provider/backend.

extent analysis

TL;DR

The most likely fix is to increase the maximum number of open files allowed by the system or adjust the file watching mechanism in OpenClaw to prevent exceeding this limit.

Guidance

  • The error EMFILE: too many open files, watch suggests that the system limit for open files is being exceeded, likely due to the file watching mechanism used by OpenClaw.
  • To verify this, check the current system limit for open files using ulimit -n (on macOS or Linux) and consider increasing it if necessary.
  • Adjusting the file watching mechanism in OpenClaw, such as by reducing the number of files being watched or implementing a more efficient watching strategy, may also help prevent this error.
  • Consider checking for any other system resource limits that might be contributing to this issue, such as memory or CPU usage.

Example

No specific code example is provided as the issue seems related to system configuration and OpenClaw's internal file watching mechanism rather than a specific code snippet.

Notes

The fact that this issue reproduces across different memory providers and backends suggests a more fundamental issue with OpenClaw's file handling or system configuration rather than a problem with a specific provider or backend.

Recommendation

Apply a workaround by increasing the system limit for open files or adjusting OpenClaw's file watching mechanism, as directly upgrading to a fixed version is not mentioned as an option in the provided issue context. This approach addresses the immediate issue of exceeding the open file limit, allowing for further investigation into optimizing OpenClaw's file handling.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

openclaw memory index --force should rebuild the memory index successfully.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING