#1879·codegraph

mcp-writer-lock tests fail on a fresh checkout without a prior build (they spawn dist/bin/codegraph.js)

Author: bompusCreated Sep 15, 2026Updated Sep 16, 2026

What happens

On a clean checkout at main (4871114), with dependencies installed and the kernel prebuild present but no dist/ built, both tests in __tests__/mcp-writer-lock.test.ts fail:

× issue #1740 — direct-mode writer lock > second CODEGRAPH_NO_DAEMON serve --mcp exits with writer-lock error
× issue #1740 — direct-mode writer lock > default daemon mode still allows two proxies to share one writer
Test Files  1 failed (1)
     Tests  2 failed (2)

First failure signature: expect(fs.existsSync(lockPath)).toBe(true) — the daemon never comes up.

Why

The file hard-codes the built CLI as its server under test:

__tests__/mcp-writer-lock.test.ts:14: const BIN = path.resolve(__dirname, '../dist/bin/codegraph.js');

and spawns node BIN serve --mcp. But package.json on main defines "test": "vitest run" with no pretest/build step, so a fresh npm ci && npm test runs these two against a nonexistent binary. Node exits immediately, no lock file appears, and each test burns its full spawn timeout (~10s + ~15s) before going red — a slow, misleading signal for a new contributor, since the failures have nothing to do with their change.

Repro

git clone https://github.com/colbymchenry/codegraph && cd codegraph
npm ci
npx vitest run __tests__/mcp-writer-lock.test.ts   # no npm run build first

Verified the same 2 failures on a pristine origin/main worktree (Linux, Node 24): identical tests, identical durations — so this is the base behavior, not a branch regression.

Possible directions

  • Skip these two with a clear message when dist/bin/codegraph.js is absent (fast, keeps npm test green on fresh checkouts), or
  • document npm run build as a prerequisite of npm test, or
  • have the test file build the binary it needs.

Related but distinct: #1782 (orphaned daemon + temp dir per run) is about cleanup after the tests run; this is about them failing when there is nothing to run.