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.
4 Likes
Thanks for identifying the issue and specifying a fix, it saved me a lot of time
Six months later, I wonder if Roon is ever going to fix this…
No news in the forum, nor any answer on a pull request I’ve submitted on Github.
You can use the fork I’ve created to submit the pull request (and exemple can be found here), or implement your own solution.
I agree that maintaining or developing the node apis
does not seem to be in the roon
team priorities though.
Thanks, that’s a good workaround.
I’ve noticed the handful of serious extension developers are using docker now so I guess this doesn’t affect them.