fix: 🐛 don't fail on disconnected websocket

This commit is contained in:
Nate Sesti 2023-09-02 02:01:50 -07:00
parent cd18705b17
commit 08766100cd
5 changed files with 26 additions and 11 deletions

View file

@ -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:

View file

@ -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

View file

@ -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(

View file

@ -50,6 +50,10 @@ If your Continue server is not setting up, try checking the console logs:
3. Select `Console`
4. Read the console logs
## Download an Older Version
If you've tried everything, reported an error, and are waiting to hear back, you can try downloading an older version of the extension. All versions are hosted on the Open VSX Registry [here](https://open-vsx.org/extension/Continue/continue). Once you've downloaded the extension, which will be a .vsix file, you can install it manually by following the instructions [here](https://code.visualstudio.com/docs/editor/extension-gallery#_install-from-a-vsix).
## Still having trouble?
Create a GitHub issue [here](https://github.com/continuedev/continue/issues/new?assignees=&labels=bug&projects=&template=bug-report-%F0%9F%90%9B.md&title=), leaving the details of your problem, and we'll be able to more quickly help you out.

View file

@ -6,6 +6,7 @@ import { PlayIcon } from "@heroicons/react/24/outline";
const DEFAULT_SIZE = "28px";
const FlashingDiv = styled.div`
margin-top: 16px;
margin: auto;
width: ${DEFAULT_SIZE};
animation: flash 1.2s infinite ease-in-out;