Repository navigation
Description
Describe the bug
A reflex run under REFLEX_USE_NPM=1 that fails preflight (node version check) still persists lockfile state into reflex.lock/ — and persists an inconsistent trio: npm rewrites the .web/package.json pins to caret ranges (npm's default save-prefix) and creates package-lock.json, which get copied into reflex.lock/ alongside the now-stale exact-spec bun.lock. The next plain (bun) run then fails bun install --frozen-lockfile.
To Reproduce
- Make the node version check fail, e.g. put a shim first on PATH that prints an old version:
The run fails on the node-version error — but by then the npm install has already run,
mkdir fakenode && printf '#!/bin/sh\nif [ "$1" = "-v" ]; then echo v22.12.0; else exec /usr/bin/node "$@"; fi\n' > fakenode/node && chmod +x fakenode/node PATH=$PWD/fakenode:$PATH REFLEX_USE_NPM=1 reflex run --frontend-port 3463 --backend-port 8465
.web/package-lock.jsonexists, and{bun.lock, package-lock.json, package.json}are copied intoreflex.lock/, withpackage.jsonrewritten to caret ranges whilebun.lockkeeps exact specs. - Run normally (bun, real node):
reflex run ...
Observed behavior
bun install --frozen-lockfile
error: lockfile had changes, but lockfile is frozen
and reflex aborts telling the user to delete reflex.lock. (The recovery advice works: after rm -rf reflex.lock the next run regenerates a clean bun-only lock.)
Expected behavior
A run that failed preflight should not have mutated persisted lockfile state at all; and switching package managers (npm↔bun) should invalidate/regenerate the other manager's lockfile instead of persisting an inconsistent trio.
Root cause (from source)
install_frontend_packages never invalidates the other package manager's persisted lockfile on a manager switch: an npm-primary install rewrites .web/package.json pins to caret ranges and creates package-lock.json, then sync_web_lockfiles_to_root persists them ALONGSIDE the stale exact-spec bun.lock; on the next run _persisted_lockfile_implies_npm() returns False because bun.lock exists, so bun runs install --frozen-lockfile against a package.json that no longer matches bun.lock and correctly refuses. Newly exposed in 0.9.9a1 by removing the postcss entry from PackageJson.OVERRIDES, which previously made the npm path fail (EOVERRIDE) before any lockfile persistence. Also, the fatal node-version error fires only AFTER _compile_app() has already run the full npm install. Fix directions: use --save-exact on npm-primary installs and/or drop/regenerate the other manager's lockfile on switch, or prefer npm when reflex.lock carries a package-lock.json newer than bun.lock.
Specifics (please complete the following information):
- Python Version: 3.11
- Reflex Version: 0.9.9a1
- OS: linux
Additional context
- Severity: low (the failure message is actionable), but the persisted-state mutation on a failed run is the real defect.
- Related but distinct (both already fixed): The persisted lockfile is out of sync with the recovered package.json #6657, package.json is copied from reflex.lock/ to .web/ without processing #6765.
- Not a strict regression: the npm↔bun sync logic is pre-existing; the OVERRIDES removal in 0.9.9a1 made the npm path reach the persistence step.
- Found during 0.9.9a1 pre-release testing; logs (
oldnode_bun.log,recovery_run.log) and the persisted inconsistentreflex.lockevidence are on branchclaude/reflex-prerelease-testing-t0sd90underprerelease-testing/2026-08-27-v0.9.9a1/prod_export/.
Activity
linear-code commentedon Aug 28, 2026
ENG-11815
fix(install): drop the other package manager's lockfile on a manager …