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

Uncaught ReferenceError in WebSocket Error Handler #149

Open
MarianoMolina opened this issue Dec 11, 2024 · 0 comments
Open

Uncaught ReferenceError in WebSocket Error Handler #149

MarianoMolina opened this issue Dec 11, 2024 · 0 comments
Assignees

Comments

@MarianoMolina
Copy link

Description:
When the LM Studio WebSocket connection fails (e.g., when trying to connect to an unavailable server), an uncaught ReferenceError is thrown due to an undefined 'event' variable in the error handler.

Steps to Reproduce:

  1. Initialize LMStudioClient with an unavailable WebSocket endpoint
  2. The connection attempt fails
  3. The SDK attempts to handle the error but crashes

Error Stack Trace:
backend-1 | [2024-12-11T12:44:12.675Z] WARN: LMStudioClient Warning: [LMStudioClient][LLM][ClientPort][WsClientTransport:AuthenticatedWsClientTransport] WebSocket error: connect ECONNREFUSED 192.168.65.254:1234
backend-1 | Stack Trace:
backend-1 | Error: connect ECONNREFUSED 192.168.65.254:1234
backend-1 | at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1278:16)
backend-1 | [2024-12-11T12:44:12.677Z] WARN: LMStudioClient Warning: [LMStudioClient][LLM][ClientPort][WsClientTransport:AuthenticatedWsClientTransport] WebSocket connection refused. This can happen if the server is not running or the client is trying to connect to the wrong path. The server path that this client is attempting to connect to is: ws://host.docker.internal:1234/llm.
backend-1 |
backend-1 | Please make sure the following:
backend-1 |
backend-1 | 1. LM Studio is running
backend-1 |
backend-1 | 2. The API server in LM Studio has started
backend-1 |
backend-1 | 3. The client is attempting to connect to the correct path
backend-1 | /app/node_modules/@lmstudio/sdk/dist/index.cjs:9840
backend-1 | this.errored(event);
backend-1 | ^
backend-1 |
backend-1 | ReferenceError: event is not defined
backend-1 | at AuthenticatedWsClientTransport.onWsError (/app/node_modules/@lmstudio/sdk/dist/index.cjs:9840:22)
backend-1 | at WebSocket. (/app/node_modules/@lmstudio/sdk/dist/index.cjs:9768:61)
backend-1 | at callListener (/app/node_modules/ws/lib/event-target.js:290:14)
backend-1 | at WebSocket.onError (/app/node_modules/ws/lib/event-target.js:230:9)
backend-1 | at WebSocket.emit (node:events:513:28)
backend-1 | at emitErrorAndClose (/app/node_modules/ws/lib/websocket.js:1041:13)
backend-1 | at ClientRequest. (/app/node_modules/ws/lib/websocket.js:881:5)
backend-1 | at ClientRequest.emit (node:events:513:28)
backend-1 | at Socket.socketErrorListener (node:_http_client:494:9)
backend-1 | at Socket.emit (node:events:513:28)

Expected Behavior:
The WebSocket connection failure should be handled gracefully, allowing the application to catch and handle the connection error.

Actual Behavior:
The SDK throws an uncaught ReferenceError when trying to handle the WebSocket error, causing the application to crash.

Impact:
Applications using the SDK cannot properly handle cases where the LM Studio server is unavailable, leading to crashes instead of graceful error handling.

Environment:

  • LM Studio SDK version: 0.4.2
  • LM Studio: 0.3.5 b9-h
  • LMS cli: 0.0.28
  • OS: Windows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants