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
If you're reporting a bug, please continue with this template.
Describe the bug
Session sets in HTTP end points and websockets have different values.
Minimal Reproducible Example
Provide a minimal code snippet that reproduces the issue. This is crucial for us to understand and fix the bug quickly.
fromfasthtml.commonimport*#from fh_frankenui.core import *importsysimportuuidapp, rt=fast_app(
pico=True,
hdrs=(
Script(src="https://unpkg.com/htmx.org/dist/ext/ws.js"), # Add WebSocket extension
),
)
@rt("/")asyncdefhome(session):
old_session_id=session.get('session_id', None)
# Get a new session_idsession['session_id'] =str(uuid.uuid4())
returnDiv(P(f"Original session_id: {old_session_id}"),
P(f"New session_id created in Main: {session['session_id']}"),
Button("Settings", hx_get="/settings", hx_target="#settings-container"),Div(id="settings-container"),
Form(Input(name="msg"), Button("Send to ws"), hx_ext="ws",
ws_connect="/ws-test",ws_send=True,), Div(id="chat-container"))
@rt('/settings')defget(session):
session_id_in=session.get('session_id', None)
session['session_id'] =str(uuid.uuid4())
returnDiv(P(f"Session_id sent to settings: {session_id_in}"), P(f"New session_id created in settings: {session.get('session_id', None)}"), id="settings-container")
@app.ws('/ws-test')asyncdefws(msg:str, send, session):
session_id_in=session.get('session_id', None)
session['session_id'] =str(uuid.uuid4())
awaitsend(Div(P(f"Session_id sent to ws: {session_id_in}"),P(f"New session_id set in ws: {session.get('session_id', None)}"), id="chat-container"))
Expected behavior
In this example I fist set session_id in "/". Then change the session_id in "/settings". Afterwards, I send the session to "/ws" and change the values of session_id. The Session_id sent to the "/ws" websocket should be the session_id value set in the "/settings" endpoint. However, as seen in the picture here, the session_id sent to the "/ws" is still the same as the value that was set in "/".
Further clicks on the two buttons would show that session_id sets in either endpoints doesn't exchange/share at all.
Environment Information
Please provide the following version information:
If you're reporting a bug, please continue with this template.
Describe the bug
Session sets in HTTP end points and websockets have different values.
Minimal Reproducible Example
Provide a minimal code snippet that reproduces the issue. This is crucial for us to understand and fix the bug quickly.
Expected behavior
In this example I fist set session_id in "/". Then change the session_id in "/settings". Afterwards, I send the session to "/ws" and change the values of session_id. The Session_id sent to the "/ws" websocket should be the session_id value set in the "/settings" endpoint. However, as seen in the picture here, the session_id sent to the "/ws" is still the same as the value that was set in "/".
Further clicks on the two buttons would show that session_id sets in either endpoints doesn't exchange/share at all.
Environment Information
Please provide the following version information:
Confirmation
Please confirm the following:
Additional context
Add any other context about the problem here.
Screenshots
If applicable, add screenshots to help explain your problem.
The text was updated successfully, but these errors were encountered: