mafintosh / mafintosh/simple-hypercore-protocol

Incompatibility with `noise-protocol@3.0.2`

Open
#9 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29
Forks
12
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lib/handshake.js at ProtocolHandshake.keyPair, then trace index.js and test.js from the reported stack. Run npm run test with noise-protocol 3.0.2 and compare the dependency behavior with the stated 3.0.1 workaround; done means the reproduction no longer throws the size-argument error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.