polkadot-js / api

Promise and RxJS APIs around Polkadot and Substrate based chains via RPC calls. It is dynamically generated based on what the Substrate runtime provides in terms of metadata.
Apache License 2.0
1.06k stars 342 forks source link

error on node v22.1.0 #5880

Open xlc opened 1 month ago

xlc commented 1 month ago
node:internal/event_target:1095
  process.nextTick(() => { throw err; });
                           ^

TypeError: Cannot read properties of null (reading 'length')
    at WebSocket.__internal__onSocketMessage (file:///Users/xiliangchen/projects/acala/chopsticks/node_modules/@polkadot/rpc-provider/ws/index.js:392:40)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:821:20)
    at WebSocket.dispatchEvent (node:internal/event_target:756:26)
    at fireEvent (node:internal/deps/undici/undici:10966:14)
    at websocketMessageReceived (node:internal/deps/undici/undici:10988:7)
    at ByteParser.run (node:internal/deps/undici/undici:11439:17)
    at ByteParser._write (node:internal/deps/undici/undici:11315:14)
    at writeOrBuffer (node:internal/streams/writable:564:12)
    at _write (node:internal/streams/writable:493:10)
    at Writable.write (node:internal/streams/writable:502:10)

Node.js v22.1.0

failed on this line

https://github.com/polkadot-js/api/blob/baaa27ba9e5d81eefe08914973bc58a65fe648f6/packages/rpc-provider/src/ws/index.ts#L482

the message is

MessageEvent {
  type: 'message',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 1240.624208
}

and message.data is null for some reason

to reproduce, run chopsticks on nodejs v22.1.0 Original issue https://github.com/AcalaNetwork/chopsticks/issues/753

TarikGul commented 1 month ago

Not surprised node v22 is giving some issues, but also happy to start working on giving it support.

TarikGul commented 1 month ago

This will most likely not be a fast fix, but I will do my best to get it resolved soon!