I have the same issue from the past week. I have no idea how to reproduce the error, but my code is here and it is hosted on streamlit cloud. It uses cache_resource
to cache some dicts, reads the uploaded text file, looks up the content in the dict, and finally outputs the converted file.
I’m using streamlit 1.19.0. The log looks something like below. When a user uploads a file, I will log info with its md5. And it seems that the error only happens when no one is using the service. Though it doesn’t seem to hurt my app now, but the log is hardly readable by the repeated error log, and I’m not sure if there is something wrong.
2023-03-09 13:38:10.037 | __main__ | INFO | [md5] e6d3a8ab17cbfd622dbda195f6ff199b [elapsed] 848.0 ms
2023-03-09 13:38:42.559 | tornado.application | ERROR | Uncaught exception GET /_stcore/stream (127.0.0.1)
HTTPServerRequest(protocol='http', host='ydk2decklist.streamlit.app', method='GET', uri='/_stcore/stream', version='HTTP/1.1', remote_ip='127.0.0.1')
Traceback (most recent call last):
File "/home/appuser/venv/lib/python3.8/site-packages/tornado/websocket.py", line 942, in _accept_connection
open_result = handler.open(*handler.open_args, **handler.open_kwargs)
File "/home/appuser/venv/lib/python3.8/site-packages/streamlit/web/server/browser_websocket_handler.py", line 123, in open
self._session_id = self._runtime.connect_session(
File "/home/appuser/venv/lib/python3.8/site-packages/streamlit/runtime/runtime.py", line 349, in connect_session
session_id = self._session_mgr.connect_session(
File "/home/appuser/venv/lib/python3.8/site-packages/streamlit/runtime/websocket_session_manager.py", line 65, in connect_session
assert (
AssertionError: session with id '8f711ddf-6ad9-448b-b153-dc3c5660dbab' is already connected!
then the similar repeats multiple times
2023-03-09 14:35:38.732 | tornado.application | ERROR | Uncaught exception GET /_stcore/stream (127.0.0.1)
AssertionError: session with id 'f30a3ed7-af05-4308-ad6c-b867140c4c99' is already connected!
2023-03-09 14:35:39.697 | tornado.application | ERROR | Uncaught exception GET /_stcore/stream (127.0.0.1)
2023-03-09 14:35:40.212 | tornado.application | ERROR | Uncaught exception GET /_stcore/stream (127.0.0.1)
2023-03-09 14:35:40.695 | tornado.application | ERROR | Uncaught exception GET /_stcore/stream (127.0.0.1)
2023-03-09 14:35:41.212 | tornado.application | ERROR | Uncaught exception GET /_stcore/stream (127.0.0.1)
2023-03-09 14:35:41.684 | tornado.application | ERROR | Uncaught exception GET /_stcore/stream (127.0.0.1)
2023-03-09 14:35:42.142 | tornado.application | ERROR | Uncaught exception GET /_stcore/stream (127.0.0.1)
2023-03-09 14:35:42.609 | tornado.application | ERROR | Uncaught exception GET /_stcore/stream (127.0.0.1)
2023-03-09 14:39:16.594 | tornado.application | ERROR | Uncaught exception GET /_stcore/stream (127.0.0.1)
AssertionError: session with id '0b3637bc-2473-4d55-a7bf-2dc0db9aec05' is already connected!
2023-03-09 14:39:17.077 | tornado.application | ERROR | Uncaught exception GET /_stcore/stream (127.0.0.1)
...
2023-03-09 14:39:19.033 | tornado.application | ERROR | Uncaught exception GET /_stcore/stream (127.0.0.1)
2023-03-09 14:54:07.185 | __main__ | INFO | [md5] 1104472dea235c7f2120ca0d89136314 [elapsed] 295.2 ms
Related streamlit source code
class WebsocketSessionManager(SessionManager):
def connect_session(
self,
client: SessionClient,
script_data: ScriptData,
user_info: Dict[str, Optional[str]],
existing_session_id: Optional[str] = None,
) -> str:
# assertion error here
assert (
existing_session_id not in self._active_session_info_by_id
), f"session with id '{existing_session_id}' is already connected!"
session_info = existing_session_id and self._session_storage.get(
existing_session_id
)
...