macOS: daemon becomes unreachable after its lock files in /tmp are deleted and recreated

Open
#3,017 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
c, macos

Research direction

Start by tracing how the daemon chooses its runtime directory and creates or checks lock files, then inspect the client path that handles a free lock when the socket is already occupied. The report reproduces the failure on macOS and suggests moving the default runtime directory outside /tmp or detecting the live socket. Done means new clients can reach the existing daemon after /tmp cleanup, or the default directory avoids that cleanup.

Written by the indexing model from the issue text.

Description

bug stability/performance

Version: 0.10.8 (npm, macOS, Apple Silicon)

What happens

After the account daemon has been running for a few days, every new client fails with:

codebase-memory-mcp: CBM daemon could not start within 30000 ms

Clients that connected earlier keep working. The old daemon is still running and still listens on its socket.

Cause (observed)

The daemon keeps its locks in /private/tmp/cbm-daemon-<uid>/. In my case:

  • The daemon started on day 0 and holds locks on the original lock files (inodes 457353xx).
  • About 4.5 days later, the lock files exist with new inodes (487612xx). The socket file is still the original one.
  • A new client locks the new files, finds them free (version_cohort.claimed_unheld), concludes no daemon runs and tries to start one. That fails because the old daemon still owns the socket, so the client times out.

I have not confirmed what deleted the lock files. macOS cleans /tmp of files that have not been accessed for a while, and the empty lock files are never read, so they qualify.

Workaround

Set CBM_RUNTIME_DIR to a folder outside /tmp, for example ~/.cache/codebase-memory-mcp/run, and restart the daemon.

Suggested fix

  • On macOS, put the default runtime folder outside /tmp, for example under CBM_CACHE_DIR or ~/Library/Caches.
  • Or let a client detect this state: the lock is free, but the socket answers. The client could then connect instead of starting a second daemon, or tell the old daemon to restart.
Dominant language
C
Stars
45.8k
Forks
3.8k
Avg merge
2d 18h
Merged PRs (30d)
108

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DeusData/codebase-memory-mcp

All issues in DeusData/codebase-memory-mcp

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.