Repository navigation
Make the production frontend build reproducible - #7564
Conversation
[Medium impact] The PR appears safe to merge; no blocking findings remain. SummaryMakes production frontend builds reproducible.
H4dr1en acknowledged that Vars with the same expression and type still share refs when their Reviews (6) · Last reviewed commit: "Keep the news fragments to the user-faci..." · Reviewed by Greptile |
Merging this PR will not alter performance1 warning
Comparing |
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.
395f503 to
33ed785
Compare
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.
There was a problem hiding this comment.
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
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.
Description
Fixes #7562.
state.jsno longer importsreflex.json. It reads the Reflex version fromenv.json, whichset_env_json()writes from values that only change with the config (REFLEX_VERSIONis added next toTRANSPORTandTEST_MODE).reflex.jsonitself is unchanged: the CLI still keeps the project hash and the last run time there.format_refreplaces 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_PROTOCOLagainstconstants.Reflex.VERSIONinEventNamespace.on_connect) gets the same value as before.Testing
test_set_env_json_holds_the_reflex_versionandtest_format_ref_names_an_f_string_var_by_its_expression_and_type.tests/unitspass.reflex export --frontend-only --no-zip --env prodruns in separate web folders:main: different manifests (manifest-0ee1b19e.js,manifest-ba20c90e.js), and every page's HTML differs;diff -rqfinds no difference inbuild/client.Type of change