Skip to content
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

WebSocket exception leading to program being stuck #429

Open
Neeraj319 opened this issue Aug 22, 2024 · 4 comments
Open

WebSocket exception leading to program being stuck #429

Neeraj319 opened this issue Aug 22, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@Neeraj319
Copy link

Describe the bug
If an exception occurs while receiving messages from the e2b servers, the following code fails to place anything in the queue, causing the entire flow to get stuck. There is currently no way for us to detect if a WebSocket error has occurred, as the client code abstracts this part away, only adding a log line. It would be beneficial if the client provided a mechanism, such as a timeout feature, that allows us as users of the client library to be aware of errors, enabling us to handle them ourselves.

The issue is happening in the following function of file eb2/sandbox/webscoket_client.py:

  async def _receive_message(self):
      try:
          if not self._ws:
              logger.error("No WebSocket connection")
              return
          async for message in self._ws:
              logger.debug(f"WebSocket received message: {message}".strip())
              self._queue_out.put(message)
      except Exception as e:
          logger.error(f"WebSocket received error while receiving messages: {e}")

To Reproduce
Happens at random, Use the CodeInterpreter class and start a websocket.

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
Should be a way for the end user to know that there was an error.

Browser console output

Terminal commands & output
WebSocket received error while receiving messages sent 1011 (internal error) keepalive ping timeout; no close frame received

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Linux
  • Browser [e.g. chrome, safari]
  • Version : e2b=0.17.1, e2b-code-interpreter=0.0.3

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

@Neeraj319 Neeraj319 added the bug Something isn't working label Aug 22, 2024
@Neeraj319 Neeraj319 changed the title WebSocket exception leading to messages being sutck. WebSocket exception leading to program being stuck Aug 22, 2024
@ValentaTomas
Copy link
Member

Hey @Neeraj319, can you try switching to the new Beta SDK (https://e2b.dev/docs/guide/beta-migration)? It gets rid of websockets and we are raising more granular exceptions.

@ValentaTomas
Copy link
Member

We also included a request timeout that you can pass to all requests/operations so you can ensure the SDK won't hang and you will get an error.

@ValentaTomas
Copy link
Member

Hey @Neeraj319 was this solved in the end?

@Neeraj319
Copy link
Author

No, thanks for suggestion though. We can close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants