Skip to content

[BUG] Watcher reload cycle drops file events pending at the restart #1852

Closed

Description

@SWSAmor

Bug Description

The local watcher restarts its awatch cycle every watch_project_reload_interval seconds.
_schedule_restart() sets the cycle's stop_event (index/watch_service.py:122-125). run() then
leaves _watch_projects_cycle(), selects projects again, and opens a new awatch
(watch_service.py:205-232). File events that are pending in the old watcher at the stop, or that
arrive before the new one is up, are never indexed, and nothing rescans afterwards. The note stays on
disk with no entity until something else touches it.

The loss depends on the reload interval, at most about one file per reload while files are being
written. With the default (300 s) we saw no loss in our runs. With a short interval it is easy to hit.

Steps To Reproduce

Throwaway home (BASIC_MEMORY_CONFIG_DIR pointing at an empty directory) with one project, config
"watch_project_reload_interval": 2, "index_delay": 1000:

  1. Start bm mcp --transport streamable-http --host 127.0.0.1 --port <port> and wait for
    Event-index watch service started in the log.
  2. Write 120 small notes into the project directory, one every 0.25 s.
  3. Wait 15 s, then
    SELECT count(*) FROM entity WHERE file_path LIKE 'n%.md'.

Expected Behavior

120 entities.

Actual Behavior

On 0.24.1: 118 of 120, with n2 and n3 missing. In earlier runs on 0.23.2 (same code path),
2–4 of 120 were lost at 2 s, about one per cycle at 30 s (3 of 400), and none at 300 s (0 of 120,
also 0 of 120 on 0.24.1).

Environment

  • OS: macOS 27.0.1 (FSEvents)
  • Python version: 3.13.17
  • Basic Memory version: 0.24.1
  • Installation method: Homebrew
  • Claude Desktop version (if applicable): n/a

Additional Context

Related but distinct: #1817 is about a project that joins the watch set at a reload. This bug
affects a project that is watched the whole time. The reload exists so config changes are picked
up, so the gap is paid on every cycle, even when nothing changed.

We mitigate with the default 300 s interval. That narrows the window but does not close it.

Possible Solution

Either of these:

  • Keep one watcher (RustNotify) across cycles and only swap the project set when it changed.
  • Restart only when the project set changed, and after any restart run an incremental scan of the
    watched projects (the checksum-based change planning already makes that cheap).

Activity

  1. added this to the v1.0 milestone on Oct 29, 2026
  2. added a commit that references this issue on Oct 29, 2026
    1719082
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions