Skip to content

Commit b6089be

Browse files
committed
move cooldown time to env var
1 parent 57e7fbc commit b6089be

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

reflex/environment.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,9 @@ class EnvironmentVariables:
696696
# How long to delay writing updated states to disk. (Higher values mean less writes, but more chance of lost data.)
697697
REFLEX_STATE_MANAGER_DISK_DEBOUNCE_SECONDS: EnvVar[float] = env_var(2.0)
698698

699+
# How long to wait between automatic reload on frontend error to avoid reload loops.
700+
REFLEX_AUTO_RELOAD_COOLDOWN_TIME_MS: EnvVar[int] = env_var(10_000)
701+
699702

700703
environment = EnvironmentVariables()
701704

reflex/state.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2487,8 +2487,6 @@ class FrontendEventExceptionState(State):
24872487
re.compile(re.escape("TypeError: null is not an object")), # Safari
24882488
re.compile(r"TypeError: can't access property \".*\" of null"), # Firefox
24892489
]
2490-
# Reload the page only once per cooldown period to avoid reload loops.
2491-
auto_reload_cooldown_time_ms: ClassVar[int] = 10000 # 10 seconds
24922490

24932491
@event
24942492
def handle_frontend_exception(
@@ -2512,10 +2510,10 @@ def handle_frontend_exception(
25122510
):
25132511
yield call_script(
25142512
f"const last_reload = parseInt(window.sessionStorage.getItem('{LAST_RELOADED_KEY}')) || 0;"
2515-
f"if (Date.now() - last_reload > {type(self).auto_reload_cooldown_time_ms})"
2513+
f"if (Date.now() - last_reload > {environment.REFLEX_AUTO_RELOAD_COOLDOWN_TIME_MS.get()})"
25162514
"{"
25172515
f"window.sessionStorage.setItem('{LAST_RELOADED_KEY}', Date.now().toString());"
2518-
"window.location.reload(true);"
2516+
"window.location.reload();"
25192517
"}"
25202518
)
25212519
prerequisites.get_and_validate_app().app.frontend_exception_handler(

0 commit comments

Comments
 (0)