-
Notifications
You must be signed in to change notification settings - Fork 176
Handle websocket error gracefully + add retry logic #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
87a0b15
to
1950089
Compare
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Reconnect Hangs on Blocked Receive Task
The reconnect
method awaits self._receive_task
without cancelling it first. If the receive task is blocked waiting for WebSocket messages, this can cause the reconnect process to hang indefinitely, unlike the close()
method's approach.
template/server/messaging.py#L70-L78
code-interpreter/template/server/messaging.py
Lines 70 to 78 in 8818ce7
async def reconnect(self): | |
if self._ws is not None: | |
await self._ws.close(reason="Reconnecting") | |
if self._receive_task is not None: | |
await self._receive_task | |
await self.connect() |
Handle connection error between the server and kernel gracefully
Add reconnect logic
Note
Adds WebSocket reconnect with retries and ping timeout, conditionally sets auth header in Python clients, and surfaces connection-loss errors to prevent hangs.
template/server/messaging.py
):reconnect()
withMAX_RECONNECT_RETRIES
andPING_TIMEOUT
; wrap send in retry loop catchingConnectionClosedError
/WebSocketException
and reconnecting.Error
andUnexpectedEndOfExecution
for ongoing executions to avoid hangs.message_id
andExecution
right before send; serialize request with_get_execute_request
.python/e2b_code_interpreter/*
):headers
withX-Access-Token
only if token present for both async and syncrun_code
andcreate_code_context
.@e2b/code-interpreter-template
(add retry) and@e2b/code-interpreter-python
(fix header issue).Written by Cursor Bugbot for commit e51313b. This will update automatically on new commits. Configure here.