node-roon-api icon indicating copy to clipboard operation
node-roon-api copied to clipboard

Incompatibility with NodeJS v22.0.0

Open NoaHimesaka1873 opened this issue 1 year ago • 4 comments

/home/yuifunami/discord-presence-roon/node_modules/@roonlabs/node-roon-api/transport-websocket.js:17
    this.ws.on('pong', () => this.is_alive = true);
            ^

TypeError: this.ws.on is not a function
    at new Transport (/home/yuifunami/discord-presence-roon/node_modules/@roonlabs/node-roon-api/transport-websocket.js:17:13)
    at RoonApi.ws_connect (/home/yuifunami/discord-presence-roon/node_modules/@roonlabs/node-roon-api/lib.js:397:23)
    at Sood.<anonymous> (/home/yuifunami/discord-presence-roon/node_modules/@roonlabs/node-roon-api/lib.js:143:66)
    at Sood.emit (node:events:520:28)
    at Socket.<anonymous> (/home/yuifunami/discord-presence-roon/node_modules/@roonlabs/node-roon-api/sood.js:213:20)
    at Socket.emit (node:events:520:28)
    at UDP.onMessage [as onmessage] (node:dgram:943:8)

Node.js v22.0.0

Arch Linux x86_64 with CachyOS x86_64-v4 packages, NodeJS v22.0.0

NoaHimesaka1873 avatar May 14 '24 15:05 NoaHimesaka1873

I will try to fix and submit a pull request. Ran into this today

mamsterla avatar Jun 19 '24 03:06 mamsterla

I did some work on this and the problem is the poly-fill for browsers now picks up the new WS in nodejs > 22.0. This version of the WS implementation has different signatures. I leave it to the Roon folks to decide whether they want to continue to support Polyfill for web sockets. The workaround is to remove the check for WebSocket defined and always load the ws library. A more complex solution would be changing the transport-websocket class to use the native nodejs one, but there seems to be lack of support for ping/pong and other differences.

mamsterla avatar Jun 19 '24 18:06 mamsterla

@mamsterla I've submitted a pull request that uses the simplest approach (forcing the use of the polyfill) to this issue. We'll see if we'll have any kind of reaction from the roon team.

OonihiloO avatar Aug 14 '24 16:08 OonihiloO

Thanks. I did the same locally but did not do the pull request. Thanks for following upOn Aug 14, 2024 9:22 AM, nihil @.***> wrote: @mamsterla I've submitted a pull request that uses the simplest approach (forcing the use of the polyfill) to this issue. We'll see if we'll have any kind of reaction from the roon team.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

mamsterla avatar Aug 14 '24 16:08 mamsterla