reflex-dev / reflex

🕸️ Web apps in pure Python 🐍
https://reflex.dev
Apache License 2.0
19.49k stars 1.11k forks source link

Cached var are not busted on hot reload #3989

Open Lendemor opened 6 days ago

Lendemor commented 6 days ago

Describe the bug Cached var are not busted when you change some values inside the var (only when there is no dependency that could trigger the cachebust)

To Reproduce Steps to reproduce the behavior:

  1. Run the snippet
    
    import reflex as rx

class MyState(rx.State): @rx.var(cache=True) def main_data(self) -> list[dict]: return [ {"id": "2"}, {"id": "3"}, ]

@rx.page(route="/mypage", title="My Page") def mypage() -> rx.Component: return rx.vstack( rx.foreach(MyState.main_data, main_data_component), spacing="0", )


2. Remove one of the two entry in the list in `main_data`
3. Wait for reload
4. The page still display the initial cached value (2 items) instead of the new one (1 item)

**Expected behavior**
Cached var value should be busted on hot-reload.
ikuV commented 4 days ago

Had the same issue, they could no reproduce it. Issues was closed.

A workaround is creating a new project and migrating the files...