Skip to content

Make the production frontend build reproducible - #7564

Merged
FarhanAliRaza merged 5 commits into
reflex-dev:mainfrom
H4dr1en:fix/reproducible-frontend-build
Oct 28, 2026
Merged

FarhanAliRaza merged 5 commits into
reflex-dev:mainfrom
H4dr1en:fix/reproducible-frontend-build

Conversation

@H4dr1en

@H4dr1en H4dr1en commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #7562.

  • state.js no longer imports reflex.json. It reads the Reflex version from env.json, which set_env_json() writes from values that only change with the config (REFLEX_VERSION is added next to TRANSPORT and TEST_MODE). reflex.json itself is unchanged: the CLI still keeps the project hash and the last run time there.
  • format_ref replaces the Var marker (<reflex.Var>{hash}</reflex.Var>) with a short digest of the Var's expression and type as text. An f-string id around a Var then gets the same ref name in every run, and Vars that differ only by type keep separate refs. It is still one ref per component, as before.

The backend's subprotocol check (HTTP_SEC_WEBSOCKET_PROTOCOL against constants.Reflex.VERSION in EventNamespace.on_connect) gets the same value as before.

Testing

  • New unit tests: test_set_env_json_holds_the_reflex_version and test_format_ref_names_an_f_string_var_by_its_expression_and_type.
  • tests/units pass.
  • On an app with f-string Var ids, two clean reflex export --frontend-only --no-zip --env prod runs in separate web folders:
    • on main: different manifests (manifest-0ee1b19e.js, manifest-ba20c90e.js), and every page's HTML differs;
    • with this change: the same manifest in both runs, and diff -rq finds no difference in build/client.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

@H4dr1en
H4dr1en requested a review from a team as a code owner October 14, 2026 15:31

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 8 files

View guided diff | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking findings remain.

Summary

Makes production frontend builds reproducible.

  • Component refs keep the same names across repeated builds.
  • Frontend exports use a fixed version for their socket connection.

H4dr1en acknowledged that Vars with the same expression and type still share refs when their VarData differs. They intentionally excluded VarData because it can contain component IDs that change between runs.

Reviews (6) · Last reviewed commit: "Keep the news fragments to the user-faci..." · Reviewed by Greptile

@codspeed

codspeed Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 20 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 148 untouched benchmarks


Comparing H4dr1en:fix/reproducible-frontend-build (ad392c4) with main (1191a38)

Open in CodSpeed

H4dr1en added 2 commits October 19, 2026 17:58
Stop bundling .web/reflex.json, whose project hash and last run time
renamed every script at each build; the page reads the Reflex version
from env.json. Drop the Var hash marker from ref names, so an f-string
id around a Var gets the same ref in every run.
Replace the Var marker with a digest of the Var's expression and type
instead of dropping it, so two Vars that differ only by type keep
separate refs, and the name is still the same in every run.
@H4dr1en
H4dr1en force-pushed the fix/reproducible-frontend-build branch from 395f503 to 33ed785 Compare October 19, 2026 16:11
@masenf masenf added the bug Something isn't working label Oct 19, 2026 — with ChatGPT Codex Connector
@masenf masenf added the on deck PRs lined up to review / merge next label Oct 27, 2026
The test passed on main whenever hash() was negative: the minus sign
became an underscore, so the hash check never matched. Pin the exact
names, which also proves they are the same in every process.

Trust the marker Var.__format__ writes: it always holds an int hash of
a registered Var.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 2 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

View guided diff | Re-trigger cubic

FarhanAliRaza
FarhanAliRaza previously approved these changes Oct 28, 2026
rx.set_value, rx.set_focus and rx.scroll_to pass any string to
format_ref, so the string can hold a marker that no Var in this process
wrote. Drop such a marker as before instead of raising ValueError or
KeyError.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working on deck PRs lined up to review / merge next

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Production builds are not reproducible: every reflex export renames every script

3 participants