- Notifications
You must be signed in to change notification settings - Fork 175
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
jakubno commented Sep 22, 2025
jakubno commented Sep 22, 2025
jakubno commented Sep 22, 2025
jakubno commented Sep 22, 2025
87a0b15
to 1950089
Compare mishushakov reviewed Sep 23, 2025
mishushakov reviewed Sep 23, 2025
mishushakov reviewed Sep 23, 2025
mishushakov reviewed Sep 25, 2025
mishushakov reviewed Sep 25, 2025
mishushakov reviewed Sep 25, 2025
jakubno commented Sep 26, 2025
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() |
mishushakov reviewed Oct 7, 2025
mishushakov approved these changes Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
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.