Skip to content

Commit

Permalink
[ENG-4194] TypeError: Cannot create property 'token' on string
Browse files Browse the repository at this point in the history
Avoid JSON encoding the reload event -- socket.io handles JSON encoding
internally now.
  • Loading branch information
masenf committed Dec 12, 2024
1 parent 1b6f539 commit 00a5632
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion reflex/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ async def process(
await asyncio.create_task(
app.event_namespace.emit(
"reload",
data=format.json_dumps(event),
data=event,
to=sid,
)
)
Expand Down
9 changes: 4 additions & 5 deletions tests/integration/test_client_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,7 @@ async def poll_for_not_hydrated():
assert await AppHarness._poll_for_async(poll_for_not_hydrated)

# Trigger event to get a new instance of the state since the old was expired.
state_var_input = driver.find_element(By.ID, "state_var")
state_var_input.send_keys("re-triggering")
set_sub("c1", "c1 post expire")

# get new references to all cookie and local storage elements (again)
c1 = driver.find_element(By.ID, "c1")
Expand All @@ -659,7 +658,7 @@ async def poll_for_not_hydrated():
l1s = driver.find_element(By.ID, "l1s")
s1s = driver.find_element(By.ID, "s1s")

assert c1.text == "c1 value"
assert c1.text == "c1 post expire"
assert c2.text == "c2 value"
assert c3.text == "" # temporary cookie expired after reset state!
assert c4.text == "c4 value"
Expand Down Expand Up @@ -690,11 +689,11 @@ async def get_sub_state():

async def poll_for_c1_set():
sub_state = await get_sub_state()
return sub_state.c1 == "c1 value"
return sub_state.c1 == "c1 post expire"

assert await AppHarness._poll_for_async(poll_for_c1_set)
sub_state = await get_sub_state()
assert sub_state.c1 == "c1 value"
assert sub_state.c1 == "c1 post expire"
assert sub_state.c2 == "c2 value"
assert sub_state.c3 == ""
assert sub_state.c4 == "c4 value"
Expand Down

0 comments on commit 00a5632

Please sign in to comment.