mafintosh / simple-hypercore-protocol

Hypercore protocol state machine
MIT License
26 stars 13 forks source link

Incompatibility with `noise-protocol@3.0.2` #9

Open wittjosiah opened 1 year ago

wittjosiah commented 1 year ago

When installed with the latest version of noise-protocol (3.0.2 published Jan 2023) the following error occurs:

in browser

simple-hypercore-protocol.js?v=268406e5:355 Uncaught TypeError: "size" argument must be a number
    at assertSize (simple-hypercore-protocol.js?v=268406e5:355:11)
    at alloc (simple-hypercore-protocol.js?v=268406e5:361:3)
    at Buffer2.alloc (simple-hypercore-protocol.js?v=268406e5:1129:14)
    at ProtocolHandshake.keyPair (simple-hypercore-protocol.js?v=268406e5:9966:30)
    at new ProtocolHandshake (simple-hypercore-protocol.js?v=268406e5:9912:58)
    at SimpleProtocol._onkeypair (simple-hypercore-protocol.js?v=268406e5:11898:27)
    at new SimpleProtocol (simple-hypercore-protocol.js?v=268406e5:11885:18)
    at main.js:3:11

Reproduction here: https://stackblitz.com/edit/vitejs-vite-caqssz?file=package.json,main.js&terminal=dev

in node

TypeError [ERR_INVALID_ARG_TYPE]: The "size" argument must be of type number. Received undefined
    at Function.alloc (node:buffer:366:3)
    at ProtocolHandshake.keyPair (simple-hypercore-protocol/lib/handshake.js:67:25)
    at new ProtocolHandshake (simple-hypercore-protocol/lib/handshake.js:14:54)
    at SimpleProtocol._onkeypair (simple-hypercore-protocol/index.js:64:23)
    at new SimpleProtocol (simple-hypercore-protocol/index.js:51:14)
    at Test.<anonymous> (simple-hypercore-protocol/test.js:8:13)
    at Test.bound [as _cb] (simple-hypercore-protocol/node_modules/tape/lib/test.js:85:17)
    at Test.run (simple-hypercore-protocol/node_modules/tape/lib/test.js:104:7)
    at Test.bound [as run] (simple-hypercore-protocol/node_modules/tape/lib/test.js:85:17)
    at Immediate.next (simple-hypercore-protocol/node_modules/tape/lib/results.js:151:7) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Reproduction: fresh clone repo, npm install, npm run test

If it's helpful I can try to look further into what is causing this when I have some time to spare. In the mean time, a workaround seems to be to pin noise-protocol to version 3.0.1.

mafintosh commented 1 year ago

Ya we stopped using the module for Hypercore 10, so not a lot of stuff happening here sorry