You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If a new tab is opened by duplicating the first, and a background task is started in both tabs, the first (by order of event trigger) tab stops seeing updates.
To Reproduce
Steps to reproduce the behavior:
Here's the code that I show in the video clip below.
importasyncioimportreflexasrxclassState(rx.State):
state_value: str="Initial value"@rx.event(background=True)asyncdefdo_something(self):
asyncwithself:
self.state_value="Initial change"awaitasyncio.sleep(2)
asyncwithself:
self.state_value="Final change"@rx.page(route="/duplicate_tabs_issue", title="Duplicate tabs issue")defindex() ->rx.Component:
returnrx.container(
rx.vstack(
rx.markdown("Minimal example to demonstrate issues with duplicated tab in Chrome."),
rx.markdown("`state.router.session.client_token` is not unique per tab when tab."),
rx.text(f"state.router.session.client_token: {rx.State.router.session.client_token}"),
rx.markdown("However, `state.router.session.session_id` does remain unique per tab."),
rx.text(f"state.router.session.session_id: {rx.State.router.session.session_id}"),
rx.divider(),
rx.text("Somehow the tabs interfere with each other during background tasks."),
rx.text(
"Expect to see 'Initial change' followed by 'Final change' after 2 seconds. But that doesn't happen if the button is clicked in the other tab before the first event finishes."
),
rx.button("Do something", on_click=State.do_something),
rx.text(f"State.state_value: {State.state_value}"),
)
)
Expected behavior
Expect that the two tabs behave independently.
Screenshots
Short video clip to show duplication of tabs, and that the background events are interrupted in the first tab by running the event in the second tab.
duplicated_tabs_issue.mp4
In fact, it seems that the second tab get's the update that was intended for first tab (seen in the video by the final_state being set too quickly in the second tab).
Specifics (please complete the following information):
Python Version: 3.12
Reflex Version: 0.6.5 -> 0.6.7
OS: WSL2
Browser (Optional): Chrome and Edge (not tried others)
Additional context
You can see that the session_id is unique per tab, but the client_token is not. I'm not sure if that is expected, but seems like it could be relevant.
Note, If the two tabs are opened separately (and don't share a client_token or session_id) then they do both behave independently.
The text was updated successfully, but these errors were encountered:
Describe the bug
If a new tab is opened by duplicating the first, and a background task is started in both tabs, the first (by order of event trigger) tab stops seeing updates.
To Reproduce
Steps to reproduce the behavior:
Here's the code that I show in the video clip below.
Expected behavior
Expect that the two tabs behave independently.
Screenshots
Short video clip to show duplication of tabs, and that the background events are interrupted in the first tab by running the event in the second tab.
duplicated_tabs_issue.mp4
In fact, it seems that the second tab get's the update that was intended for first tab (seen in the video by the
final_state
being set too quickly in the second tab).Specifics (please complete the following information):
Additional context
You can see that the
session_id
is unique per tab, but theclient_token
is not. I'm not sure if that is expected, but seems like it could be relevant.Note, If the two tabs are opened separately (and don't share a
client_token
orsession_id
) then they do both behave independently.The text was updated successfully, but these errors were encountered: