ipfs / js-ipfs

IPFS implementation in JavaScript
https://js.ipfs.tech
Other
7.44k stars 1.25k forks source link

"peerId must be an instance of peer-id" on webpack'd version of js-ipfs #3284

Closed aphelionz closed 4 years ago

aphelionz commented 4 years ago

Severity: High

Description:

Running the tests for orbit-db-store, I find that this test works fine in node.js but when run in the browser (via minified webpack), it gives me the error: peerId must be an instance of peer-id

  1. Test: https://github.com/orbitdb/orbit-db-store/blob/fix/replication-tests/test/replicator.spec.js
  2. Webpack Config: https://github.com/orbitdb/orbit-db-store/blob/fix/replication-tests/conf/webpack.tests.config.js
  3. PR (see CircleCI tests) https://github.com/orbitdb/orbit-db-store/pull/98

Steps to reproduce the error:

$ git clone https://github.com/orbitdb/orbit-db-store
$ cd orbit-db-store
$ make rebuild

Or you can view the error here in the CircleCI test results. https://app.circleci.com/jobs/github/orbitdb/orbit-db-store/573

achingbrain commented 4 years ago

Do you have multiple versions of peer-id in your dependency tree? There should be only 0.14.1.

achingbrain commented 4 years ago

How do I repro this? I did:

$ git clone https://github.com/orbitdb/orbit-db-store
$ cd orbit-db-store
$ make rebuild
$ npm test

It ran the tests in node and mocha-headless-chrome and they passed. Doing the install has modified the package-lock.json file though.

aphelionz commented 4 years ago

ah sorry - git checkout fix/replciation-tests

aphelionz commented 4 years ago

Also npm ls peer-id shows 0.14.1 across the board

achingbrain commented 4 years ago

peerId is undefined - the tests are trying to get two browser nodes that don't have any listening addresses to dial each other (the .addresses array is empty).

That this worked previously may be something to do with the upgrade to libp2p@0.29.0 in the latest js-ipfs (cc @vasco-santos). <- edit, this hasn't worked previously, the test is new..

You may need to spin up a webrtc-star signalling server as part of the test so they can dial each other - we do something similar in our tests.

aphelionz commented 4 years ago

Ahhhhh of course. This can be closed. I know what to do. Thank you!