Skip to content

fix(clean): remove the workspaces' node_modules too (npm's babylon lockfile count was missing) - #223

Merged
lukekarrys merged 1 commit into
mainfrom
lk/npm-babylon-lockfile-count
Nov 18, 2026
Merged

lukekarrys merged 1 commit into
mainfrom
lk/npm-babylon-lockfile-count

Conversation

@lukekarrys

Copy link
Copy Markdown
Member

The bug

Since #218, npm's process count in the babylon lockfile variation is missing. In run 44250431401 (job "Run Benchmarks (babylon, lockfile)"), the counted install exited 1 about 2 s after starting:

Warning: strace'd install exited with 1 for npm, skipping process count

npm's timed lockfile installs in the same job passed, and babylon cache has npm's count.

Root cause

clean_node_modules removed only the root node_modules. On babylon, vlt (and pnpm, bun, the yarns) also write packages/*/node_modules; vlt fills 84 of them with symlinks into the root node_modules/.vlt store, e.g.

packages/dev/sharedUiComponents/node_modules/react -> ../../../../node_modules/.vlt/~npm~react@18.3.1/node_modules/react (DANGLING)

Once the root is removed they dangle, and nothing cleaned them: not the prepares, not clean_all (git checkout -- packages/ only restores tracked files). 452 such symlinks were left in the fixture after vlt's timed run.

When npm then installs without a lockfile with those present, it records them in package-lock.json as empty entries and leaves them in place; the next install from that lockfile throws. Captured by keeping the counted install's output (and the npm debug log):

npm error Invalid Version:
npm verbose stack TypeError: Invalid Version:
    at new SemVer (semver/classes/semver.js:56:13)
    at compare (semver/functions/compare.js:5:32)
    at Object.eq (semver/functions/eq.js:4:29)
    at Node.canDedupe (@npmcli/arborist/lib/node.js:1147:32)
    at PlaceDep.pruneDedupable (@npmcli/arborist/lib/place-dep.js:433:14)
    ...
    at async Arborist.buildIdealTree (build-ideal-tree.js:188:7)

Minimal reproduction on a two-workspace project with dangling vlt-style symlinks in packages/*/node_modules: npm install exits 0 and writes

packages/a/node_modules/is-odd {}
packages/b/node_modules/is-number {}

into the lockfile; rm -rf node_modules && npm install then fails with Invalid Version: .

That is why only the counted install failed: the counted installs run after every tool's timed runs, so npm's warmup (which writes the lockfile) started from vlt's leftovers, while npm's timed runs come first and never see them. It also means that, in the lockfile and cache variations, every tool after npm started its timed runs from whatever earlier tools had put in the workspaces' node_modules.

The fix

  • clean_node_modules removes every node_modules directory in the project, not only the root one. Hidden directories (.aube, .upm-store, ...) are the tools' own stores and are skipped; clean_package_manager_files removes them whole. The node_modules variations don't call clean_node_modules in their prepares, so they are unchanged.
  • process-count.sh keeps the counted install's output in <pm>-process-count-output.log and prints it when the install fails, so the next failure explains itself.
  • A test for clean_node_modules, and a note in METHODOLOGY.md that earlier babylon lockfile/cache numbers started from other tools' workspace node_modules.

Verified

Inside an isolated namespace (fresh tmpfs $HOME, vlt.json pointed at registry.npmjs.org), BENCH_INCLUDE=npm,vlt BENCH_WARMUP=0 BENCH_RUNS=1 bash suite/scripts/variations/lockfile.sh ... babylon lockfile:

🤖 Generated with Claude Code

… lockfile count exists

clean_node_modules only removed the root node_modules. On babylon, vlt (and
pnpm, bun, the yarns) also write packages/*/node_modules; vlt fills them with
symlinks into the root node_modules/.vlt store, which dangle once the root is
removed and survive every clean, including clean_all. When npm then installs
with those present, it records them in package-lock.json as empty entries
("packages/x/node_modules/foo": {}) and the next install from that lockfile
fails with "Invalid Version: " (semver.eq in Node.canDedupe). That is why
npm's babylon lockfile process count has been missing since #218: the
counted install's warmup starts after every other tool has run, while the
timed npm runs come first and never see the leftovers.

Remove every node_modules directory in the project (hidden directories,
the tools' own stores, excepted), keep the counted install's output in
<pm>-process-count-output.log and print it when the install fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
benchmarks Ready Ready Preview Nov 18, 2026 8:14am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 18, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 18 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1139a4c9-eaa3-46ab-b50a-79164f0ff2a6
Commits

Reviewing files that changed from the base of the PR and between f3f8286 and 0c7a790.

Files selected for processing: 4

  • docs/METHODOLOGY.md
  • suite/scripts/clean-helpers.sh
  • suite/scripts/clean-helpers.test.js
  • suite/scripts/process-count.sh
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@lukekarrys
lukekarrys merged commit ce57083 into main Nov 18, 2026
78 checks passed
@lukekarrys
lukekarrys deleted the lk/npm-babylon-lockfile-count branch November 18, 2026 08:36

This branch was previously deployed

1 inactive deployment
Benchmark — 0c7a7907 Deployed Nov 18, 2026 by lukekarrys via Run Benchmarks (build-cache, next) #1462
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant