Skip to content

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

Closed

Description

@bompus

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.

Activity

  1. bompus commented on Sep 16, 2026

    @bompus
    ContributorAuthor

    Independent confirmation from a clean worktree today: rebased #1842 onto d0996a2 and ran __tests__/cli-sync-stale-index.test.ts with no dist/ present — 7/7 fail with MODULE_NOT_FOUND for dist/bin/codegraph.js (node:internal/modules/cjs/loader in the output). After tsc && npm run copy-assets in the worktree, the same file goes 7/7 green. So the suite's failure mode on a fresh checkout is exactly as described: it assumes a prior build. (Related: literal-compiled-index.test.ts in #1867 degrades gracefully via describe.runIf(fs.existsSync(built)) — it skips instead of failing.)

  2. colbymchenry commented on Sep 27, 2026

    @colbymchenry
    Owner

    Thanks for the detailed report, @bompus, and thanks for using CodeGraph! This is fixed on main by #2021, which builds on @danusha2345's #1924 (thank you!): the test suite now builds a missing or stale dist/ before running, so the writer-lock tests pass on a fresh checkout without a prior npm run build. The fix will be in the next release.

  3. added a commit that references this issue on Sep 28, 2026
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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions