-
Notifications
You must be signed in to change notification settings - Fork 60
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 connection errors go unhandled. #223
Comments
@DamienDeepgram curious about this. Was an error event listener set up at the time this errored? For e.g. const dgConnection = deepgram.listen.live({ model: "nova" });
dgConnection.on(LiveTranscriptionEvents.Open, () => {
dgConnection.on(LiveTranscriptionEvents.Transcript, (data) => {
console.log(data);
});
dgConnection.on(LiveTranscriptionEvents.Error, (err) => {
console.error(err);
});
}); I've been reading a bit about this. It appears that (despite what you and I are both seeing) neither object throws an error?? The docs say it won't throw, it will only ever emit an error event. I don't get an error event, but I do see an uncaught exception. :notlikethis: |
Further reading, I realise now our websocket library is using a custom event when a connection handshake errors with a 404. We should add a listener for this and expose it to the users. |
I was using the node-live sample in this repo here: https://github.com/deepgram/deepgram-js-sdk/blob/main/examples/node-live/index.js It looks like that does not handle the errors. So if I add the missing error handler this would catch there errors automatically nice. I added a PR to add in the error handling See: #231 |
Hi dear all, Allow me to re-open this issue as I believe it is still present in the Deepgram JS SDK - after a good amount of debugging the issue. It is easy reproducible using the server implementation here - https://github.com/deepgram-devs/node-live-example/blob/main/server.js It turned out that my API key has expired - however, this is not the root cause of the issue. If attempting to connect to the Deepgram WSS API directly I’ve received the correct error - 401 Unauthorised and the connection was denied. The SDK does not handle the 401 Unauthorised event properly perhaps because another error is thrown in the middle of the whole process. The error is the same as reported in the beginning of this issue. Environment:
Steps to Reproduce:
Further info: When connecting via Postman directly to the WSS API - Expected behaviour:
I hope this helps improving the SDK or someone stuck like me in debugging the error. Thank you for the well-thought and architected SDK. |
+1, having some problem. moved the error and close listeners at the same level as open listener, but still throws unhandled and crushes the app |
Here is the full error I get
Here is what the emitted error contains
The text was updated successfully, but these errors were encountered: