Skip to content

index_repository: deterministic contained worker crash (0-byte log) when cache dir + derived project name exceed Windows MAX_PATH #1450

Closed

Description

@junk151516

Version

codebase-memory-mcp 0.9.0

Platform

Windows 11 amd64

Install channel

GitHub release archive

Binary variant

ui

What happened, and what did you expect?

index_repository dies with a contained worker crash, deterministically, when the cache directory path plus the derived project name exceed the Windows MAX_PATH limit of 260 characters.

{"status":"error","outcome":"exit_nonzero","hint":"Indexing worker crashed on a file. The crash was contained (the server survived). Re-run to retry; a future release isolates the culprit file."}

Two things make this expensive to diagnose:

  1. The hint points at the wrong thing. "Crashed on a file … re-run to retry" sends you looking for a culprit source file and encourages retrying. Neither helps: the input is 16 lines of Python across 3 files, and retrying fails 100% of the time.
  2. The worker log is 0 bytes. logs/.worker-*.log lives under the same over-long cache directory, so the worker cannot open it either — the one diagnostic that would explain the failure is silenced by the failure itself.

Expected: either long paths handled transparently, or an explicit error naming the path and its length.

Reproduction

Any dummy project works — the content is irrelevant, only the path lengths matter. Three files, 16 LOC:

svc/api/routes.py      # FastAPI APIRouter(prefix="/api/items") + one @router.get("")
svc/client/fetch.py    # httpx.get("/api/items")

Index it with the cache directory set alongside it, both under a deep path:

export CBM_CACHE_DIR="<deep>/_cache"
cli index_repository --repo-path "<deep>\svc" --mode moderate

The derived project name is the repo path with separators replaced, so a deep repo produces a long .db filename inside an already-long cache dir:

cache dir : 151 chars
db name   : 149 chars   (C-Users-...-scratchpad-repro-svc-a.db)
full path : 301 chars   >  MAX_PATH (260)

Isolation matrix — same binary, same 16-LOC project, --mode moderate:

repo path cache path result
deep short 4 / 4 indexed
short deep 4 / 4 indexed
deep deep 0 / 8 indexed (and 0/20 in an earlier round)

Neither path is a problem on its own; it is the sum, which is what MAX_PATH constrains. Moving the same project to C:\tmp\r1133 with a short cache dir indexes 12/12 without a single failure.

Logs

logs/.worker-<pid>.log is created and stays at 0 bytes for every failed run. Nothing is flushed, so there is no stack, no path, and no errno.

Project scale

25 nodes / 41 edges. Scale is irrelevant here — this is a path-length failure, not a resource one.

Suggested fix

In rough order of preference:

  1. Use the extended-length path prefix (\\?\) for the store's own files on Windows, which lifts the 260-character limit for the .db, -wal, -shm and worker logs.
  2. Bound the derived project name — hash or truncate it past some length instead of embedding the full path verbatim in the filename.
  3. Failing both, fail explicitly. An error that names the path and its length would have turned this from an afternoon into a minute. This is the same fail-loudly principle already accepted for Inline property map in MATCH pattern silently matches nothing — should error if unsupported #1111 and cross-repo-intelligence: --target-projects flag silently parses to zero targets; with raw-JSON args the worker crashes (0-byte log) #1133.

Worth noting that (3) alone would help more than it sounds: the current combination of a misleading hint and a 0-byte log actively points away from the cause.

Related

Possibly a contributing factor in some reports of contained worker crashes with empty logs (#1132, #1379), though I would not assume it accounts for all of them — I have separately observed nondeterministic contained crashes with short paths, which this does not explain.

Confirmations

  • I searched existing issues and this is not a duplicate.
  • My reproduction uses shareable code (a dummy snippet or a public OSS repository), not proprietary code.

Activity

  1. added
    bugSomething isn't working
    priority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.
    on Sep 5, 2026
  2. DeusData commented on Sep 25, 2026

    @DeusData
    Owner

    Thank you so much, @junk151516, for this report. The isolation matrix (deep+short, short+deep, deep+deep) and the path-length breakdown made the cause clear right away. Your three suggestions all turned into fixes on main:

    • Extended-length paths: from v0.10.0 (0baddf7), every file-system path of 240 characters or more is sent to Win32 in the \\?\ form. The SQLite store opens follow the same rule since f36ab45, so the cache DB, its -wal/-shm and the logs are no longer limited to MAX_PATH.
    • The 0-byte worker log: the real cause was that Windows fully buffers a redirected stderr. From v0.10.5 (87717b0) the worker log is unbuffered and starts with a header naming the version, pid, repo path and arguments. A failing worker now always leaves evidence behind.
    • exit_nonzero no longer gets the misleading "crashed on a file, re-run" hint.

    We re-ran your exact scenario on real Windows 11 with a current build: a 161-character repo path, a 165-character cache path and a 329-character DB path. It indexed 3 out of 3 times, and the worker logs were non-empty. So we're closing this as fixed. If you still see a contained crash with short paths on v0.11.0 (the separate nondeterministic case you mentioned), please open a new issue and attach the worker log. It will have content now, and thanks to your push here it should tell us exactly where it stopped.

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

    bugSomething isn't workingpriority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.stability/performanceServer crashes, OOM, hangs, high CPU/memoryux/behaviorDisplay bugs, docs, adoption UXwindowsWindows-specific issues

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions