Skip to content

memory-core file watcher does not detect new files (chokidar v5 glob incompatibility) #33585

Description

@tijun97

Description

The memory-core plugin's file watcher (ensureWatcher()) passes glob patterns like memory/**/*.md to chokidar v5. However, chokidar v5 removed built-in glob support (no picomatch/anymatch dependency). The path is treated as a literal file path, stat() fails silently, and the watcher never registers for the memory/ directory.

As a result, new .md files created in workspace/memory/ are never indexed into SQLite until a gateway restart or manual memory_search trigger.

Steps to Reproduce

  1. Start gateway normally (memory-core registers, existing files indexed)
  2. Create a new file: echo "# Test" > workspace/memory/test-new.md
  3. Wait 60 seconds
  4. Check: sqlite3 ~/.openclaw/memory/main.sqlite "SELECT path FROM files WHERE path LIKE '%test-new%';"
  5. Result: empty — file not indexed

Root Cause

In manager-D8h-GoiI.js line ~2134:

watchPaths.add(path.join(this.workspaceDir, "memory", "**", "*.md"));

This creates a path like /path/to/workspace/memory/**/*.md.

Chokidar v5 (5.0.0) does NOT resolve globs — it passes this string directly to stat() which fails (no such file). The watcher is effectively a no-op for the memory directory.

Confirmed via test: watching the directory path works, watching the glob does not:

// Does NOT fire "add":
chokidar.watch("memory/**/*.md", { ignoreInitial: true })

// DOES fire "add":
chokidar.watch("memory/", { ignoreInitial: true })

Suggested Fix

Replace glob patterns with directory paths in ensureWatcher():

// Before (broken with chokidar v5):
watchPaths.add(path.join(this.workspaceDir, "memory", "**", "*.md"));

// After (works):
watchPaths.add(path.join(this.workspaceDir, "memory"));

Add .md extension filtering in the ignored option or in markDirty().

Environment

  • OpenClaw: 2026.3.1
  • chokidar: 5.0.0
  • Node: v24.13.1
  • OS: macOS 15.2 Sequoia (Darwin 24.2.0, Apple Silicon)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions