Răsfoiți Sursa

[ENG-4776] Write stateful pages marker earlier when should_compile is False (#4868)

Fix issue where the presence of `.web/backend` without
`.web/backend/stateful_pages.json` was breaking detection statefulness.
Masen Furer 2 luni în urmă
părinte
comite
2febedf239
1 a modificat fișierele cu 7 adăugiri și 1 ștergeri
  1. 7 1
      reflex/app.py

+ 7 - 1
reflex/app.py

@@ -1103,6 +1103,9 @@ class App(MiddlewareMixin, LifespanMixin):
                     console.debug(f"Evaluating page: {route}")
                     console.debug(f"Evaluating page: {route}")
                     self._compile_page(route, save_page=should_compile)
                     self._compile_page(route, save_page=should_compile)
 
 
+            # Save the pages which created new states at eval time.
+            self._write_stateful_pages_marker()
+
             # Add the optional endpoints (_upload)
             # Add the optional endpoints (_upload)
             self._add_optional_endpoints()
             self._add_optional_endpoints()
 
 
@@ -1145,6 +1148,8 @@ class App(MiddlewareMixin, LifespanMixin):
                     )[:10]
                     )[:10]
                 )
                 )
             )
             )
+            # Save the pages which created new states at eval time.
+            self._write_stateful_pages_marker()
 
 
         # Add the optional endpoints (_upload)
         # Add the optional endpoints (_upload)
         self._add_optional_endpoints()
         self._add_optional_endpoints()
@@ -1366,7 +1371,8 @@ class App(MiddlewareMixin, LifespanMixin):
             for output_path, code in compile_results:
             for output_path, code in compile_results:
                 compiler_utils.write_page(output_path, code)
                 compiler_utils.write_page(output_path, code)
 
 
-        # Write list of routes that create dynamic states for backend to use.
+    def _write_stateful_pages_marker(self):
+        """Write list of routes that create dynamic states for the backend to use later."""
         if self._state is not None:
         if self._state is not None:
             stateful_pages_marker = (
             stateful_pages_marker = (
                 prerequisites.get_backend_dir() / constants.Dirs.STATEFUL_PAGES
                 prerequisites.get_backend_dir() / constants.Dirs.STATEFUL_PAGES