Node-roon-api broken with NodeJS release > 22.0

I upgraded to NodeJS 22.0 and found that the roon-http-extension-api failed. I had to do a deep dive and found that the Websocket implementation in Node is no longer behind a feature flag. This would be fine except that the semantics for the new Websocket implementation differ from the one in the ws library and the one in browsers. Specifically in the file transport-websocket.js there is a Polyfill that detects whether Websocket is defined. If it is, it uses the native one with the different signature (no ws.on method). I have worked around it by forcing the use of the ws library (i.e. global.Websocket = require(‘ws’)). However this would break browser compatibility. The long answer is that someone at Roon needs to decide how to handle the native Websockets in NodeJS now and update the transport-websocket.js correctly. I did a test and validated that forcing the use of ws library works on the extenstion roon-extension-http-api which is what I wanted.

2 Likes