Skip to content

fix persisted bun lockfile recovery#6660

Open
harsh21234i wants to merge 4 commits into
reflex-dev:mainfrom
harsh21234i:fix/persisted-lockfile-sync-6657
Open

fix persisted bun lockfile recovery#6660
harsh21234i wants to merge 4 commits into
reflex-dev:mainfrom
harsh21234i:fix/persisted-lockfile-sync-6657

Conversation

@harsh21234i

Copy link
Copy Markdown

What changed

  • Detect when bun install --frozen-lockfile fails because the recovered package.json and persisted bun.lock are
    out of sync.
  • Automatically retry the install without --frozen-lockfile so Bun can reconcile the files.
  • Preserve the existing error behavior for unrelated installation failures.
  • Add regression coverage for the recovery flow.

Why

A persisted bun.lock could contain updated dependencies while the persisted package.json remained stale. This
caused reflex run to fail and required users to manually delete reflex.lock.

The new recovery flow regenerates the mismatched lockfile automatically, allowing the application to start normally.

Fixes #6657

Validation

  • uv run pytest tests/units/test_prerequisites.py -q
  • uv run ruff check reflex/utils/js_runtimes.py tests/units/test_prerequisites.py
  • git diff --check

@harsh21234i harsh21234i requested a review from a team as a code owner June 13, 2026 08:00
@greptile-apps

greptile-apps Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR updates a docstring in _run_initial_install to reference reflex.lock instead of reflex.lock/package.json, and reformats a few lines for PEP 8 compliance. The PR description claims automatic retry of bun install without --frozen-lockfile was implemented, but no such retry logic exists in the diff.

  • The frozen-lockfile error path in js_runtimes.py is functionally identical before and after: it still raises SystemExit(1) immediately with a message telling the user to manually delete the directory.
  • The test update only reformats the function signature and updates a docstring — it does not verify any retry behavior, which is consistent with there being no retry in the implementation.
  • Issue The persisted lockfile is out of sync with the recovered package.json #6657 (users being forced to manually delete reflex.lock) remains unresolved.

Confidence Score: 4/5

Safe to merge as-is, but the advertised fix is not present — the frozen-lockfile recovery still requires manual user intervention.

The only functional change is a docstring correction. No existing behavior is broken, but the advertised fix (automatic retry without --frozen-lockfile) is entirely absent from the implementation.

reflex/utils/js_runtimes.py — the frozen-lockfile branch at line 501 needs the retry logic the PR description promises.

Important Files Changed

Filename Overview
reflex/utils/js_runtimes.py Only docstring and formatting changes — the advertised automatic retry logic was not added; frozen-lockfile failures still exit immediately with SystemExit(1)
tests/units/test_prerequisites.py Function signature reformatted and docstring updated; test still only checks the error-message path (SystemExit + "out of sync" output), not any retry behavior

Comments Outside Diff (1)

  1. reflex/utils/js_runtimes.py, line 501-510 (link)

    P1 Claimed retry logic is not implemented

    The PR description states it "automatically retry the install without --frozen-lockfile so Bun can reconcile the files," but this block still raises SystemExit(1) immediately on a frozen-lockfile mismatch — exactly as it did before the PR. No retry attempt is made; the user is still asked to manually delete the directory. The entire premise of the fix described in the PR (automatic recovery rather than manual intervention) is absent from the implementation.

Reviews (4): Last reviewed commit: "remove automatic bun lockfile relock" | Re-trigger Greptile

Comment thread reflex/utils/js_runtimes.py Outdated
Comment thread tests/units/test_prerequisites.py Outdated
@harsh21234i

Copy link
Copy Markdown
Author

hey @masenf can you look into this?

@masenf

masenf commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

We can't automatically ignore the user's lock file. Choosing to relock by deleting the reflex.lock directory or reflex.lock/bun.lock is something the user must explicitly do.

My other PR #6658 always syncs the package.json file into .web which helps mitigate some of the staleness that can creep in, for example when changing git branches across a package.json change.

@harsh21234i

Copy link
Copy Markdown
Author

hey @masenf
Updated in c309061.

I removed the automatic relock/retry behavior. The frozen-lockfile mismatch now exits with explicit guidance telling
the user to delete reflex.lock and rerun, so regenerating the lockfile remains an explicit user action.

Validation:

  • uv run pytest tests/units/test_prerequisites.py -q
  • uv run ruff check reflex/utils/js_runtimes.py tests/units/test_prerequisites.py

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.

The persisted lockfile is out of sync with the recovered package.json

2 participants