Skip to content

fix persisted bun lockfile recovery#6660

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

fix persisted bun lockfile recovery#6660
harsh21234i wants to merge 3 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 changes _run_initial_install so that a bun --frozen-lockfile mismatch triggers an automatic retry without the flag, instead of immediately failing with a manual-delete hint. Two tests cover the new happy path and failure path.

  • The retry logic and detection guard (_is_bun_package_manager) are correct, and the failure-path message now includes the directory hint the user needs.
  • The show_status call for the recovery process is missing suppress_errors=True: stream_logs raises SystemExit(1) internally when the recovery exits non-zero, so the custom "Failed to regenerate" message and the directory-deletion hint are unreachable dead code in production. The new test masks this by mocking show_status to return a list rather than raise.

Confidence Score: 4/5

Safe to merge with one fix: the recovery show_status call needs suppress_errors=True or the actionable error message will never reach the user when recovery fails.

The retry logic is correct and the happy path works. When recovery fails, show_status raises SystemExit(1) internally before the custom error block runs, so the user-facing directory-deletion hint is never shown.

reflex/utils/js_runtimes.py — the show_status call in the recovery block (line 518) and the corresponding test mock in test_prerequisites.py

Important Files Changed

Filename Overview
reflex/utils/js_runtimes.py Adds retry-without-frozen-lockfile recovery for bun lockfile mismatch; the recovery's show_status call omits suppress_errors=True, making the actionable error message unreachable when recovery fails
tests/units/test_prerequisites.py Adds two new tests for the recovery flow (happy path and failure path); the failure-path test passes because its show_status mock returns a list rather than raising, masking the production bug

Reviews (3): Last reviewed commit: "Merge branch 'reflex-dev:main' into fix/..." | Re-trigger Greptile

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

Copy link
Copy Markdown
Author

hey @masenf can you look into this?

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

1 participant