Skip to content

0.9.12a1: @rx.var(cache=False) withheld from a delta by a downstream get_delta filter is never re-sent (#6946 records "last sent" while building the delta, not on delivery) #7212

Closed

Description

@masenf

Describe the bug

#6946 dedupes unchanged uncached computed vars by remembering the last value sent per client. The memo is written while the delta is built, not when it is delivered: BaseState.get_delta (reflex/state.py ~2380) calls cvar._record_delta_value(...), and ComputedVar._record_delta_value (packages/reflex-base/src/reflex_base/vars/base.py:2689) immediately stores instance.__last_delta_<js_expr> = (token, key). Nothing rolls it back when a downstream get_delta wrapper removes the entry, or when delivery fails. So a @rx.var(cache=False) that a filter withholds is marked "sent"; once the filter stops withholding it, the same value is deduped away and the client keeps the stale value until the var's value changes again.

This is not a synthetic pattern: the get_delta docstring documents that downstream code overrides it with a self-only signature, and reflex-enterprise 0.9.5 does exactly that for post-event auth filtering (reflex_enterprise/auth/oidc/state.py:2529); its redeliver_protected() (auth/enforcement.py:960-995) re-marks withheld vars dirty on the assumption that the end-of-event delta re-delivers them — the assumption this breaks for cache=False vars. Regression vs 0.9.11.post1, which delivers the value. The existing primitive for this, _suppress_delta_recording() (reflex/state.py:317), is private and only used by reflex/istate/shared.py:122.

To Reproduce

Browser-free (uv pip install --prerelease=allow 'reflex==0.9.12a1'):

import reflex as rx

_SHARED = {"v": "default"}
AUTHENTICATED = False


class ProbeState(rx.State):
    hits: int = 0

    @rx.var(cache=False)
    def shared_label(self) -> str:
        return f"shared={_SHARED['v']}"


_orig = rx.State.get_delta


def filtered_get_delta(self):
    delta = _orig(self)
    if AUTHENTICATED:
        return delta
    return {sn: {k: v for k, v in sd.items() if "shared_label" not in k} for sn, sd in delta.items()}


rx.State.get_delta = filtered_get_delta


def sent(label, st):
    d = st.get_delta()
    print(label, any("shared_label" in k for sd in d.values() for k in sd), d)
    st._clean()


st = ProbeState(_reflex_internal_init=True)
st._mark_dirty(); sent("1 anon initial       ", st)
_SHARED["v"] = "SERVER-ONLY-SECRET"; st.hits += 1; sent("2 anon event         ", st)
AUTHENTICATED = True; st.hits += 1; sent("3 after login        ", st)   # expected: True
st.hits += 1; sent("4 after another event", st)                           # expected: True
  • 0.9.12a1: steps 3 and 4 print False — shared_label is never delivered again.
  • 0.9.11.post1: True for both.

Same result in a browser with a State subclass overriding get_delta (dev/in-memory, dev + redis single worker, prod + redis 9 workers): the websocket delta after the filter is lifted carries only the other vars and the page shows the stale value until the var's value changes again. Under redis the stale __last_delta_… memo is visible inside the pickled state, so this is neither a prod-build nor a multi-worker artifact.

Expected behavior

An uncached var that was withheld from the delivered delta is re-sent as soon as it is no longer withheld (0.9.11.post1 behaviour).

Suggested fix shape

Record the "last sent" key after the delta has been filtered/emitted, or expose _suppress_delta_recording() / a post-filter hook to get_delta overrides — instead of recording while building the delta.

Specifics (please complete the following information):

  • Python Version: 3.11.15
  • Reflex Version: 0.9.12a1 / reflex-base 0.9.12a1 (regression vs 0.9.11.post1)
  • OS: Linux (Ubuntu 24.04 container)

Additional context

0.9.12a1 pre-release QA campaign FINDING-003, reproduced through reflex-enterprise auth, in pure reflex (dev, dev + redis, prod + redis) and by two independent adversarial verifiers. Evidence and scripts: prerelease-testing/2026-09-18-v0.9.12a1/ — event_loop/ (page /filtered of elapp, scripts/s_filtered.py, verification/), ent_mcp_oidc/verification/2026-09-19-adversarial/pure_delta_memo.py, and FINDINGS.md.

Activity

  1. added theissue type on Sep 19, 2026
  2. linear-code commented on Sep 19, 2026

    @linear-code
  3. added a commit that references this issue on Sep 19, 2026
    dc7da49
  4. added a commit that references this issue on Sep 21, 2026
    9f7d399
  5. added
    release-train
    on Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    release-train

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions