You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(errors): enhance WebSocket error output and abstract connection setup
- Add DeepgramWebSocketError class with detailed debugging info including
HTTP status codes, Deepgram request IDs, response headers, and connection state
- Abstract common connection event setup pattern into reusable
setupConnectionEvents() method in AbstractLiveClient
- Update all live clients (Listen, Agent, Speak) to use abstracted pattern
- Eliminate ~45 lines of duplicated connection event handling code
- Maintain full backward compatibility with existing error event handlers
Addresses customer feedback about difficulty debugging "non-101 status code"
errors by exposing the actual HTTP status and request ID that were previously
hidden behind generic Node.js WebSocket error messages.
Copy file name to clipboardExpand all lines: src/packages/ListenLiveClient.ts
+13-12Lines changed: 13 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -51,19 +51,15 @@ export class ListenLiveClient extends AbstractLiveClient {
51
51
* - When a message is received, it parses the message and emits the appropriate event based on the message type, such as `LiveTranscriptionEvents.Metadata`, `LiveTranscriptionEvents.Transcript`, `LiveTranscriptionEvents.UtteranceEnd`, and `LiveTranscriptionEvents.SpeechStarted`.
52
52
*/
53
53
publicsetupConnection(): void{
54
-
if(this.conn){
55
-
this.conn.onopen=()=>{
56
-
this.emit(LiveTranscriptionEvents.Open,this);
57
-
};
58
-
59
-
this.conn.onclose=(event: any)=>{
60
-
this.emit(LiveTranscriptionEvents.Close,event);
61
-
};
62
-
63
-
this.conn.onerror=(event: ErrorEvent)=>{
64
-
this.emit(LiveTranscriptionEvents.Error,event);
65
-
};
54
+
// Set up standard connection events (open, close, error) using abstracted method
55
+
this.setupConnectionEvents({
56
+
Open: LiveTranscriptionEvents.Open,
57
+
Close: LiveTranscriptionEvents.Close,
58
+
Error: LiveTranscriptionEvents.Error,
59
+
});
66
60
61
+
// Set up message handling specific to transcription
62
+
if(this.conn){
67
63
this.conn.onmessage=(event: MessageEvent)=>{
68
64
try{
69
65
constdata: any=JSON.parse(event.data.toString());
@@ -84,6 +80,11 @@ export class ListenLiveClient extends AbstractLiveClient {
0 commit comments