Skip to content

Websocket handlers shouldn't throw exceptions #12

@Stevenic

Description

@Stevenic

My relay server instance sometimes dies with this error...

file:///c:/source/stevenic/synthos/node_modules/@openai/realtime-api-beta/lib/conversation.js:202
        throw new Error(`response.audio.delta: Item "${item_id}" not found`);
        ^

Error: response.audio.delta: Item "item_AEjLKjxXWZnPmwwdAm9UY" not found
    at response.audio.delta (file:///c:/source/stevenic/synthos/node_modules/@openai/realtime-api-beta/lib/conversation.js:202:15)
    at RealtimeConversation.processEvent (file:///c:/source/stevenic/synthos/node_modules/@openai/realtime-api-beta/lib/conversation.js:292:27)
    at handler (file:///c:/source/stevenic/synthos/node_modules/@openai/realtime-api-beta/lib/client.js:278:49)
    at handlerWithDispatch (file:///c:/source/stevenic/synthos/node_modules/@openai/realtime-api-beta/lib/client.js:282:31)
    at RealtimeAPI.dispatch (file:///c:/source/stevenic/synthos/node_modules/@openai/realtime-api-beta/lib/event_handler.js:134:7)
    at RealtimeAPI.receive (file:///c:/source/stevenic/synthos/node_modules/@openai/realtime-api-beta/lib/api.js:178:10)
    at WebSocket.<anonymous> (file:///c:/source/stevenic/synthos/node_modules/@openai/realtime-api-beta/lib/api.js:129:14)
    at WebSocket.emit (node:events:517:28)
    at Receiver.receiverOnMessage (c:\source\stevenic\synthos\node_modules\ws\lib\websocket.js:1220:20)
    at Receiver.emit (node:events:517:28)

Node.js v18.20.2
error Command failed with exit code 1.

The issue is that internal socket handlers are throwing exceptions which can't easily be caught. If you hit an error like this you should map it to a error event of some sort...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions