diff options
author | Nate Sesti <sestinj@gmail.com> | 2023-09-02 02:01:50 -0700 |
---|---|---|
committer | Nate Sesti <sestinj@gmail.com> | 2023-09-02 02:01:50 -0700 |
commit | 08766100cdb3638b3300ae4b700f8ec2af6b9a8a (patch) | |
tree | 20f4c313b22fe373fa8a617d16a589a555266c81 /continuedev/src/continuedev/server | |
parent | cd18705b172501b66419134e0c054f571b073a1b (diff) | |
download | sncontinue-08766100cdb3638b3300ae4b700f8ec2af6b9a8a.tar.gz sncontinue-08766100cdb3638b3300ae4b700f8ec2af6b9a8a.tar.bz2 sncontinue-08766100cdb3638b3300ae4b700f8ec2af6b9a8a.zip |
fix: :bug: don't fail on disconnected websocket
Diffstat (limited to 'continuedev/src/continuedev/server')
-rw-r--r-- | continuedev/src/continuedev/server/ide.py | 21 | ||||
-rw-r--r-- | continuedev/src/continuedev/server/meilisearch_server.py | 7 | ||||
-rw-r--r-- | continuedev/src/continuedev/server/session_manager.py | 4 |
3 files changed, 21 insertions, 11 deletions
diff --git a/continuedev/src/continuedev/server/ide.py b/continuedev/src/continuedev/server/ide.py index 89fcd0d1..1c88d2a0 100644 --- a/continuedev/src/continuedev/server/ide.py +++ b/continuedev/src/continuedev/server/ide.py @@ -185,13 +185,20 @@ class IdeProtocolServer(AbstractIdeProtocolServer): return other_msgs async def _send_json(self, message_type: str, data: Any): - if self.websocket.application_state == WebSocketState.DISCONNECTED: - logger.debug( - f"Tried to send message, but websocket is disconnected: {message_type}" - ) - return - logger.debug(f"Sending IDE message: {message_type}") - await self.websocket.send_json({"messageType": message_type, "data": data}) + # TODO: You breakpointed here, set it to disconnected, and then saw + # that even after reloading, it couldn't connect the server. + # Is this because there is an IDE registered without a websocket? + # This shouldn't count as registered in that case. + try: + if self.websocket.application_state == WebSocketState.DISCONNECTED: + logger.debug( + f"Tried to send message, but websocket is disconnected: {message_type}" + ) + return + logger.debug(f"Sending IDE message: {message_type}") + await self.websocket.send_json({"messageType": message_type, "data": data}) + except RuntimeError as e: + logger.warning(f"Error sending IDE message, websocket probably closed: {e}") async def _receive_json(self, message_type: str, timeout: int = 20) -> Any: try: diff --git a/continuedev/src/continuedev/server/meilisearch_server.py b/continuedev/src/continuedev/server/meilisearch_server.py index e64588e7..11099494 100644 --- a/continuedev/src/continuedev/server/meilisearch_server.py +++ b/continuedev/src/continuedev/server/meilisearch_server.py @@ -69,10 +69,13 @@ async def ensure_meilisearch_installed() -> bool: else: non_existing_paths.add(path) - if len(non_existing_paths) > 0 and os.name != "nt": + if len(non_existing_paths) > 0: # Clear the meilisearch binary if meilisearchPath in existing_paths: - os.remove(meilisearchPath) + try: + os.remove(meilisearchPath) + except: + pass existing_paths.remove(meilisearchPath) # Clear the existing directories diff --git a/continuedev/src/continuedev/server/session_manager.py b/continuedev/src/continuedev/server/session_manager.py index 05b54c89..aea20ef9 100644 --- a/continuedev/src/continuedev/server/session_manager.py +++ b/continuedev/src/continuedev/server/session_manager.py @@ -159,9 +159,9 @@ class SessionManager: async def send_ws_data(self, session_id: str, message_type: str, data: Any): if session_id not in self.sessions: - raise SessionNotFound(f"Session {session_id} not found") + logger.warning(f"Session {session_id} not found") + return if self.sessions[session_id].ws is None: - # logger.debug(f"Session {session_id} has no websocket") return await self.sessions[session_id].ws.send_json( |