Skip to content

Dev server restarts when another worktree installs dependencies #544

Closed

Description

@Jacksondr5

Problem

A dev server under test restarts itself whenever another worktree installs or removes its node_modules. The restart cancels live agent turns and breaks the browser session, with nothing changed in the worktree being tested.

J5 creates and removes worktrees constantly, so this hits most long live tests. Past test sessions logged 29 to 31 restarts each, and one cancelled a real Claude turn.

Cause

apps/server/package.json runs the dev server as node --watch src/bin.ts. On Linux that watches every file the server has loaded, including about 1,200 files under node_modules/.pnpm. pnpm hardlinks those files from its shared store, so each worktree's copy is the same inode. When another worktree links or unlinks them, the link count changes, inotify fires, and Node restarts.

Evidence from 2026-10-11:

  • The watcher of a running dev server had 2,300 watched files: 1,064 source files and 1,236 under node_modules/.pnpm, 708 of them hardlinked to the store. State, sqlite files and build output were not watched.
  • A restart at 13:52:38 local lined up with another worktree's install starting at 13:52:37.998.
  • Reproduced in a scratch directory: ln of a loaded file caused a restart, and so did rm of that link. With --watch --watch-path=./src neither did, and a real edit under src still restarted.

Fix

Narrow the watch to source directories:

node --watch --watch-path=src --watch-path=../../packages src/bin.ts

Before merging, check that the recursive watch on packages does not follow the node_modules symlinks back in.

This is a one-line edit to an upstream-owned file, so it needs a FORK.md entry. Upstream has no no-watch switch and no issue about this, and would hit the same problem with any two pnpm worktrees, so it is a candidate to offer back (#276).

Jackson approved narrowing the watch on 2026-10-11.

Part of the agent live-testing work.

Activity

  1. added
    bug
    on Oct 12, 2026
  2. added a commit that references this issue on Oct 12, 2026
    276950b
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions