openclaw - 💡(How to fix) Fix chokidar v5 glob pattern memory/**/*.md fails to detect file changes (incremental index never triggers) [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#56825Fetched 2026-04-08 01:47:24
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0

File changes under memory/**/*.md are not detected by chokidar v5, so incremental memory indexing never triggers after the initial session-start sync.

Root Cause

OpenClaw memory manager builds watcher paths as glob patterns:

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

chokidar v5.0.0 appears to have a regression with glob patterns — **/*.md watches the parent directory but fails to emit change events for files matching the glob pattern that already exist at watch start.

Fix Action

Fix / Workaround

  • All agents using the default memory-core plugin are affected
  • Only session-start (or gateway restart) triggers full reindex
  • Incremental updates after initial sync never happen
  • Workaround: restart gateway to force reindex

Code Example

// This WORKS — detects change events
chokidar.watch(["/path/to/workspace/memory/"], {ignoreInitial: true})
// This DOES NOT WORK — no change events
chokidar.watch(["/path/to/workspace/memory/**/*.md"], {ignoreInitial: true})

---

path.join(this.workspaceDir, "memory", "**", "*.md")
RAW_BUFFERClick to expand / collapse

Bug

OpenClaw version: 2026.3.24 (cff6dc9) Node.js: v25.8.2 OS: Linux 6.8.0-88-generic (x64)

Description

File changes under memory/**/*.md are not detected by chokidar v5, so incremental memory indexing never triggers after the initial session-start sync.

Steps to Reproduce

  1. Configure an agent with memorySearch.enabled: true (default)
  2. Start gateway — session-start sync indexes existing files successfully
  3. Add or modify any .md file under the agent workspace memory/ directory
  4. Wait for debounce period (default 1.5s)
  5. No sync is triggered — dirty flag is never set, no reindex occurs

Verified

// This WORKS — detects change events
chokidar.watch(["/path/to/workspace/memory/"], {ignoreInitial: true})
// This DOES NOT WORK — no change events
chokidar.watch(["/path/to/workspace/memory/**/*.md"], {ignoreInitial: true})

Tested with the exact chokidar version bundled in OpenClaw v2026.3.24:

  • chokidar.watch(["path/to/memory/**/*.md"])no events on existing file change
  • chokidar.watch(["path/to/memory/"])change events detected correctly

Root Cause

OpenClaw memory manager builds watcher paths as glob patterns:

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

chokidar v5.0.0 appears to have a regression with glob patterns — **/*.md watches the parent directory but fails to emit change events for files matching the glob pattern that already exist at watch start.

Expected Behavior

File changes under memory/ should be detected and trigger incremental reindex.

Impact

  • All agents using the default memory-core plugin are affected
  • Only session-start (or gateway restart) triggers full reindex
  • Incremental updates after initial sync never happen
  • Workaround: restart gateway to force reindex

Suggested Fix

Replace glob pattern with directory watch + filename filter, or downgrade chokidar to v4.x where glob patterns work correctly.

extent analysis

Fix Plan

To fix the issue with chokidar v5 not detecting file changes under memory/**/*.md, we will replace the glob pattern with a directory watch and a filename filter.

Step-by-Step Solution

  • Watch the memory directory instead of using a glob pattern:
const watcher = chokidar.watch(path.join(this.workspaceDir, "memory"), {
  ignoreInitial: true,
  persistent: true,
  recursive: true
});
  • Filter the watched files to only include .md files:
watcher.on('all', (event, path) => {
  if (path.endsWith('.md')) {
    // Trigger incremental reindex
    this.reindexMemory();
  }
});

Alternatively, you can downgrade chokidar to v4.x where glob patterns work correctly:

npm install chokidar@4

or

yarn add chokidar@4

Verification

To verify that the fix worked, follow these steps:

  • Start the gateway and wait for the initial session-start sync to complete.
  • Modify an existing .md file under the memory directory.
  • Wait for the debounce period (default 1.5s).
  • Check if the incremental reindex is triggered and the dirty flag is set.

Extra Tips

  • Make sure to update the chokidar version in your package.json file if you choose to downgrade.
  • If you encounter any issues with the filename filter, you can use a more robust filtering library like micromatch.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING