Skip to content

Process persisted package json before web sync - #6792

Merged
masenf merged 2 commits into
reflex-dev:mainfrom
harsh21234i:fix/process-persisted-package-json-6765
Jul 29, 2026
Merged

masenf merged 2 commits into
reflex-dev:mainfrom
harsh21234i:fix/process-persisted-package-json-6765

Conversation

@harsh21234i

Copy link
Copy Markdown
Contributor

Summary

Fixes #6765.

This updates the root lockfile sync path so package.json is processed before being mirrored into .web/.

Previously, a stale or corrupted reflex.lock/package.json could be copied directly into .web/package.json, which
could drop Reflex-managed scripts like dev and export.

Changes

  • Add a dedicated package.json sync helper instead of treating it like a raw lockfile.
  • Re-render persisted package.json content through Reflex’s package JSON compiler.
  • Preserve the existing .web/package.json when no root persisted package.json exists.
  • Add regression coverage for both direct sync and frontend install repair behavior.

@harsh21234i
harsh21234i requested a review from a team as a code owner July 17, 2026 15:24
@codspeed

codspeed Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 26 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing harsh21234i:fix/process-persisted-package-json-6765 (3b29939) with main (2edaf12)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@greptile-apps

greptile-apps Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a bug where a stale or corrupted reflex.lock/package.json could be byte-copied directly into .web/package.json, potentially dropping Reflex-managed dev and export scripts. The fix re-routes the package.json sync through _compile_package_json(), which re-renders the file with guaranteed framework scripts rather than blindly mirroring it.

  • Adds sync_root_package_json_to_web() that renders the persisted root package.json through Reflex's template before writing it to .web/, replacing the former byte-copy path.
  • When no root persisted package.json exists, falls back to the previous no-op behaviour (web file preserved as-is).
  • Adds two regression tests: one for direct sync and one covering the frontend install repair path.

Confidence Score: 5/5

Safe to merge — the change is narrowly scoped to the package.json sync path and the fallback for a missing root file preserves the existing no-op behaviour.

The new helper re-renders the persisted package.json through the same compiler used by initialize_package_json, so the framework-owned scripts are always guaranteed to be present. The fallback when the root file is absent is identical to the previous behaviour. Two regression tests cover both the direct sync case and the install-repair path. No unrelated code is touched.

No files require special attention.

Important Files Changed

Filename Overview
reflex/utils/frontend_skeleton.py Adds sync_root_package_json_to_web() that re-renders the persisted package.json via _compile_package_json() instead of byte-copying; sync_root_lockfiles_to_web updated to call it.
tests/units/test_prerequisites.py Adds two focused regression tests covering the direct sync and install-repair scenarios introduced by the fix.
news/6765.bugfix.md Changelog entry for the bugfix.

Reviews (2): Last reviewed commit: "Update reflex/utils/frontend_skeleton.py" | Re-trigger Greptile

Comment thread reflex/utils/frontend_skeleton.py Resolved
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@harsh21234i

Copy link
Copy Markdown
Contributor Author

hey any update @claude @masenf ??

@masenf masenf added the In Review Actively being reviewed by reflex team member label Jul 29, 2026

@masenf masenf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the contribution!

@masenf
masenf merged commit a8857cd into reflex-dev:main Jul 29, 2026
107 checks passed
benedikt-bartscher pushed a commit to benedikt-bartscher/reflex that referenced this pull request Jul 30, 2026
* Process persisted package json before web sync

* Update reflex/utils/frontend_skeleton.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: Harsh Thakare <[email protected]>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
masenf pushed a commit that referenced this pull request Aug 4, 2026
The fragment was named after #6792, the PR that introduced the regression,
which would render a changelog link to the wrong PR. Reword the text to
describe the user-visible symptom rather than the implementation change.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018WXodmwe6tFZ6DkweqArij
masenf added a commit that referenced this pull request Aug 4, 2026
* Apply package.json overrides after the frozen install

A Reflex upgrade that introduces a new entry in
`constants.PackageJson.OVERRIDES` broke `reflex run` for any app with a
persisted `reflex.lock/`. Restoring `reflex.lock/package.json` merged the
framework overrides in on the way to `.web`, so the restored package.json no
longer matched the `bun.lock` it was persisted alongside, and the initial
`bun install --frozen-lockfile` aborted with `error: lockfile had changes, but
lockfile is frozen`. Upgrading 0.9.7 (override `cookie`, direct dep
`[email protected]`) to 0.9.8a2 (override `[email protected]`) reproduces it: the new
override forces a different resolution for a package the lockfile already
pinned.

`overrides` participate in dependency resolution, so they now stay exactly as
persisted while the package.json/lockfile pair is restored, and the
framework-owned entries are merged into `.web/package.json` right after the
frozen install instead. The dependency adds that follow resolve against them
and refresh the lockfile; when there is nothing to add, a non-frozen install
reconciles it so the persisted pair is ready for the next frozen install.

`scripts` are unaffected and keep being repaired during the restore, since
they play no part in resolution.

Also add `OVERRIDES` to the frontend-install cache fingerprint, so an upgrade
that changes only the overrides invalidates the cache and actually applies them.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018WXodmwe6tFZ6DkweqArij

* Point news fragment at #6844 and reword for release notes

The fragment was named after #6792, the PR that introduced the regression,
which would render a changelog link to the wrong PR. Reword the text to
describe the user-visible symptom rather than the implementation change.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018WXodmwe6tFZ6DkweqArij

---------

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

In Review Actively being reviewed by reflex team member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

package.json is copied from reflex.lock/ to .web/ without processing

2 participants