openai / openai-realtime-api-beta

Node.js + JavaScript reference client for the Realtime API (beta)
MIT License
661 stars 154 forks source link

globalThis.Websocket usage in node > 22.4.0 #56

Open tschellenbach opened 2 weeks ago

tschellenbach commented 2 weeks ago

See https://nodejs.org/api/globals.html#websocket

image

The if statement in api.js globalThis.WebSocket doesn't work as intended in recent node versions.

halilxibrahim commented 2 weeks ago

If I am not mistaken,It seems that the globalThis.WebSocket reference isn’t functioning as expected in Node.js version 22.4.0 and later. This issue might be due to changes in how Node handles globalThis.WebSocket. Conditional Loading of WebSocket: If globalThis.WebSocket is undefined, we can manually require the WebSocket module: if (typeof globalThis.WebSocket === 'undefined') { globalThis.WebSocket = require('ws'); }

the-wc commented 2 weeks ago

Had this issue with v22.2.0 too. Ended up downgrading for the demo.

NoRKin commented 2 weeks ago

Same issue in bun & deno