Repository navigation
Description
An existing session can reload showing compiled defaults even though its current state is still stored on the server. A Python-callable state value registered by reflex-enterprise triggers this when its serializer checks a process-local bundled-library registry that was never populated in the backend worker. That serializer raises inside JSON encoding, so the entire hydrate packet is lost, including unrelated valid state vars.
This is pre-existing in Reflex 0.9.10.post2 and reproduced in 0.9.11a1 with reflex-enterprise 0.9.5. The detailed independent verification narrows and extends the original finding: it is not limited to dev, and an unsupported value without a registered serializer does not cause this failure.
Minimal reproduction
Install reflex-enterprise==0.9.5 alongside the tested Reflex version. In a normal Reflex app (with app_name="minapp" in rxconfig.py):
import reflex as rx
import reflex_enterprise as rxe
def cell_renderer(params: rx.Var) -> rx.Component:
return rx.text("cell")
class MinState(rx.State):
count: int = 0
col_defs: list[dict] = [{"field": "name", "cell_renderer": cell_renderer}]
@rx.event
def increment(self):
self.count += 1
def index():
return rx.vstack(
rx.text(MinState.count, id="count"),
rx.button("Increment", on_click=MinState.increment),
)
app = rxe.App()
app.add_page(index)- Start
reflex runfrom a fresh compile, before making any source edits. - Click Increment three times: the UI shows
3. - Reload the page: the UI shows
0and the backend reportsValueError: Library @radix-ui/themes is not bundled. - Click once: the UI jumps to
4. The server retained the state; only delivery failed.
The campaign's minimized app and driver require no AG Grid, memo component, patched demo, or special routes. Inspect ent_aggrid/verification/issue2_hydrate_delta/app/ for the exact tested source.
Affected configurations and controls
| Configuration | Observed result |
|---|---|
| Fresh dev worker that skips compilation | Reload shows 0; next click shows 4 |
Separately started backend serving a production build with __REFLEX_SKIP_COMPILE=true |
Same lost state delivery; generic error banner in the UI |
Default reflex run --env prod Granian path that compiles in the serving process |
No failure |
| Dev after the first source hot reload triggers a real compile | No failure |
| Same probe without enterprise, using an object with no serializer | Encodes as null; unrelated state survives reload |
Both versions were independently checked. on_load still runs and is_hydrated can become true despite the lost hydrate packet. This affects reload/reconnect of an existing session most visibly, rather than first visits already displaying defaults.
Mechanism and ownership
reflex_components_radix/plugin.pyregisters@radix-ui/themesduringRadixThemesPlugin.enter_component, in the full compile walk.- The early, non-compiling path in
reflex/compiler/compiler.py:compile_appevaluates pages and returns before bundled-library setup. Its registry contains onlyreact,@emotion/react,$/utils/context, and$/utils/state, even though the deployed frontend includes Radix. reflex_enterprise/vars.py:serialize_lambdavalidates that incomplete registry at websocket serialization time and raisesValueError.- The exception escapes the JSON
default=hook throughreflex_base.utils.serializers.serialize→format.json_dumps→reflex.app._sio_dumps→ Socket.IO packet encoding. The entire packet is aborted.
The framework-side action is to make bundled-library metadata match the actual frontend build in non-compiling workers, including dependencies discovered during component traversal. Persisting/restoring the compiled registry is one possible direction. The enterprise serializer also should not treat missing compilation context as proof a deployed library is absent. Silently swallowing arbitrary serializer errors would hide real data problems and is not a sufficient fix.
Expected: unrelated session state is delivered on reload, and backend bundle validation reflects the shipped build. Raw exception text in dev is intentional; production correctly uses a generic message, so error-message disclosure is not part of this bug.
Verified workaround
At app module import time:
from reflex_base.components.dynamic import bundle_library
bundle_library("@radix-ui/themes")The campaign verified zero exceptions and a reload preserving 3 with that registration. It survives in a non-compiling worker; the compiling process can register Radix through its plugin.
Evidence and duplicate check
See the verification section near the end of ent_aggrid/NOTES.md and verification/issue2_hydrate_delta/: reports/min_a1_dev_report.json, reports/min_0910_dev_report.json, reports/deploylike_report.json, the corresponding log excerpts, probe_registry.py, serve_deploy_like.py, and reports/workaround_report.json.
Searched open and closed Reflex issues for hydrate, serialization, unserializable values, bundled libraries, and missing dispatchers. Related #6975 / #7016 concern registrations discarded during frontend compilation and subpath rewriting; this report concerns absent compiled metadata in a non-compiling backend. #6019 concerns client-side missing dispatchers after packet delivery. Neither covers the packet being dropped during backend serialization. No matching existing issue found.
Source: prerelease finding 018, recorded against Reflex 0.9.11a1 and compared with 0.9.10.post2. See the full campaign report and cluster notes and reproduction artifacts. Findings and verification status above are from that campaign; this filing does not claim a new browser rerun.
Activity
linear-code commentedon Sep 11, 2026
ENG-12359
masenf commentedon Sep 11, 2026
Status on the published 0.9.11a2 batch: the failure moved earlier
Re-ran the minimized reproduction from this issue against published packages only (reflex 0.9.11a2 + reflex-base 0.9.11a2 + reflex-enterprise 0.9.5), with 0.9.11a1 running beside it as a control.
0(withon_load-ranandis_hydratedtrue), next click shows4. TheValueErrorappears twice in the log and the worker survives.Deterministic — reproduced twice, the second time after
rm -rf .web.Raising at compile time is the better failure mode, so this is a step in the right direction rather than something to revert: the silent packet loss is gone and the problem is now loud and immediate. What remains is that the app still cannot run, and the error's advice cannot be followed from where it is raised — the value lives in a state field's default, and the exception happens while the worker is importing the app module.
Why the new extraction misses this case
The
serialize_initial_valuehook that #7109 added inreflex/compiler/utils.py::_compile_initial_state(new in a2 — it does not exist in the 0.9.11a1 wheel) only bundles when the value is a component:The value here is a plain Python callable. reflex-enterprise turns it into a
LiteralLambdaVar, and the component it renders — and therefore@radix-ui/themes— is reachable only through that Var's var data, never throughisinstance(value, Component).Suggested direction
Extend the initial-state dynamic-import extraction so it also looks at fields that are a
Varwhose_get_all_var_data()carries components, and bundle those imports the same way it bundles a component's own. That should cover this case.One wrinkle for whoever picks it up: the validation currently raises inside the serializer (
LiteralLambdaVar.create→_validate_and_extend_return_expr), so an extraction hook that inspects the value first has to reach the var data without going through the validating construction — or the validation has to be deferred until after bundling — otherwise the hook raises before it gets the chance to register anything.Worth weighing against the fact that removing the dynamic-bundling feature altogether is on the table; if that is where this ends up, this is not worth much investment.
Evidence
From the 0.9.11a2 published-package validation:
PUBLISHED_VALIDATION_RESULTS.md(the "018 — separately labelled adjacent check" section, with the smallest reproduction), pluspublished_review_a2/out/f018_a{1,2}_dev.json,published_review_a2/logs/minrx_a{1,2}_*.tail.logand the driverpublished_review_a2/scripts/drive_018.py.The production-build / separately-started non-compiling backend variant of the check was not run on a2: the app cannot start at all there, so that configuration has no meaning until the startup failure is resolved.
Generated by Claude Code
prerelease-testing: reframe the 018 result as a moved failure, not a …
masenf commentedon Sep 11, 2026
Follow-up on the "raises before it can register anything" wrinkle from my previous comment — agreed, that half is reflex-enterprise's, and there are two shapes it could take.
The var data is already in hand at the raise site.
LiteralLambdaVar._validate_and_extend_return_expr(reflex_enterprise/vars.py:121in 0.9.5) computesreturn_expr._get_all_var_data()and then walksvd.importsagainstget_bundled_libraries(), raising on the first package that is not registered (:162-168). That is exactly the data a framework-side initial-state extraction would want, so enterprise can either register those imports itself instead of raising, or expose a non-validating construction and let the caller bundle first.One ordering caveat either way. In
compile_app, both non-compiling branches callutils._compile_initial_state(app._state)and return before_reset_bundled_libraries_for_compile()and the plugin dependency registration (reflex/compiler/compiler.py:1234and:1254vs:1264-1271). So in a non-compiling worker, registering at that moment cannot repair a frontend that was already built — it only helps when the same process goes on to build. Which is the same conclusion this issue already reaches from the other direction: a non-compiling worker's registry should not be treated as authoritative evidence that a deployed library is absent.Or drop the mechanism. Replacing
LiteralLambdaVarwith function-stylerx.memofor ag-grid-style callback props would remove the bespoke__reflex['<pkg>']?.<tag>runtime lookup, and the bundled-library validation with it, in favour of components reflex already compiles and bundles through the normal path. Enterprise's own error messages in that same function already steer users to@rx.memofor the custom-code and hooks cases — this would extend that to the whole mechanism rather than keeping two ways to ship a callback.Recording this here because reflex-enterprise is a separate tracker; happy for it to move.
Generated by Claude Code
harsh21234i commentedon Sep 12, 2026
This change addresses the original non-compiling-worker hydration failure by restoring the bundled-library registry before state serialization. However, the newer 0.9.11a2 failure occurs earlier, while reflex- enterprise imports the app module and validates the callable, before Reflex can restore the registry.
That remaining startup failure appears to require a coordinated reflex-enterprise change or a maintainer-approved framework API. I do not want to claim this PR completely resolves #7096 without covering that path.