Skip to content

Commit 5d0db8c

Browse files
committed
handle indexerror
1 parent c0fccfb commit 5d0db8c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

reflex/app.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,8 +1994,12 @@ async def on_connect(self, sid: str, environ: dict):
19941994
sid: The Socket.IO session id.
19951995
environ: The request information, including HTTP headers.
19961996
"""
1997-
query_params = urllib.parse.parse_qs(environ.get("QUERY_STRING"))
1998-
await self.link_token_to_sid(sid, query_params.get("token", [])[0])
1997+
query_params = urllib.parse.parse_qs(environ.get("QUERY_STRING", ""))
1998+
token_list = query_params.get("token", [])
1999+
if token_list:
2000+
await self.link_token_to_sid(sid, token_list[0])
2001+
else:
2002+
console.warn(f"No token provided in connection for session {sid}")
19992003

20002004
subprotocol = environ.get("HTTP_SEC_WEBSOCKET_PROTOCOL")
20012005
if subprotocol and subprotocol != constants.Reflex.VERSION:

0 commit comments

Comments
 (0)