Js-ipfs: Example: Circuit Realying broken

Created on 5 Jul 2018  ·  15Comments  ·  Source: ipfs/js-ipfs

Severity: Medium

Description:

At the time of creating this issue (latest master https://github.com/ipfs/js-ipfs/commit/c1ee2474b08928ad64dac9148b7852f6c272387e), following the tutorial instructions in the circuit-relaying example results in the following building error:

❯ npm start

> [email protected] start /Users/pascalprecht/projects/ipfs/js-ipfs/examples/circuit-relaying
> parcel index.html

Server running at http://localhost:1234 
🚨  /Users/pascalprecht/projects/ipfs/js-ipfs/examples/circuit-relaying/node_modules/ipfs/src/core/components/pin.js:22:17: /Users/pascalprecht/projects/ipfs/js-ipfs/examples/cir
 20 | }aying/node_modules/ipfs/src/core/components/pin.js: "pin" is read-only
  21 | 
> 22 | module.exports = function pin (self) {
     |                  ^
  23 |   const repo = self._repo
  24 |   const dag = self.dag
  25 |   const pinset = createPinSet(dag)

Steps to reproduce the error:

$ npm install
$ npm start
P3 dihard kinbug

Most helpful comment

Deleting and rebuilding examples/circuit-relaying/package-lock.json fixes the build error. I'm going to update the deps and submit PR for it.

All 15 comments

@alanshaw this seems to be the same issue as with the aegir docs generation, right?

Seems Alan actually fixed it and it's in master now: https://github.com/ipfs/js-ipfs/commit/a08a17dfa06951b07cd92877b281246e55442429

@PascalPrecht can you try again and close the issue if it's been fixed?

@alanshaw this seems to be the same issue as with the aegir docs generation, right?

Yep, that's been resolved - hopefully this example now works!

Verifying this now.

Hm... so on latest master npm install is now failing with:

npm WARN [email protected] No repository field.

npm ERR! path /Users/pascalprecht/projects/ipfs/js-ipfs/examples/circuit-relaying/node_modules/.staging/ipfs-23eee25e/node_modules/@sindresorhus/is
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/Users/pascalprecht/projects/ipfs/js-ipfs/examples/circuit-relaying/node_modules/.staging/ipfs-23eee25e/node_modules/@sindresorhus/is' -> '/Users/pascalprecht/projects/ipfs/js-ipfs/examples/circuit-relaying/node_modules/.staging/@sindresorhus/is-108eaae6'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

@VictorBjelkholm can you confirm this? ^

@PascalPrecht I can confirm, I'm seeing this too. Am investigating.

Deleting and rebuilding examples/circuit-relaying/package-lock.json fixes the build error. I'm going to update the deps and submit PR for it.

Thanks @olizilla let me know if you need any help

@PascalPrecht the adventure continues!

  • removing the package-lock.json and rebuild fixes the error and let's you npm install again.
  • running the example, my browser nodes never listed an address in the addresses box. IPFS booted and a peerId was listed, bit no address.
  • building the example to test the new parcelJS, I got an exciting error which looks like another bundle optimisation error that doesn't occur when running parcel in dev mode.
Uncaught TypeError: require(...) is not a function
    at Object.parcelRequire.tvhY.../nodeify (index-browser.js:5)
    at u (pull.js:32)
    at p (index.js:46)
    at Object.parcelRequire.6YZP../hmac (index.js:3)

The stack is mangled but, the require that fails is here:
https://github.com/libp2p/js-libp2p-crypto/blob/ad478454d86787fffed30730605d6c76a36b4d61/src/hmac/index-browser.js#L5

https://github.com/libp2p/js-libp2p-crypto/blob/ad478454d86787fffed30730605d6c76a36b4d61/src/webcrypto.js#L5-L13

the error suggests that the export from webcrypto.js is not a exporting a function, but it does: https://github.com/libp2p/js-libp2p-crypto/blob/ad478454d86787fffed30730605d6c76a36b4d61/src/webcrypto.js

Could be a parcel specific esm vs commonJs default module export mix up, but both the exporting and the requiring module are written in commonJs, so that'd be an egregious mix up. I haven't had time to dig into it yet. @PascalPrecht if you have a moment to test it out and see if you get the same that'd be ace!

running the example, my browser nodes never listed an address in the addresses box. IPFS booted and a peerId was listed, bit no address.

I can confirm this. I don't get the parcel error tho. Anything specific required to reproduce that one apart from npm install and npm start ?

Ah yes, the bundle error is from running npm run build to create the optimised static site to dist then running a static file server over it like npx http-server dist.

The reason the addresses are not being printed out anymore is because of the changes made to libp2p config (breaking change). The circuit config is not looked up under the EXPERIMENTAL flag anymore, hence it never gets enabled. I've got a PR addressing it here - https://github.com/ipfs/js-ipfs/pull/1443.

I wonder if the change to move circuit-relay from under EXPERIMENTAL was intentional or did it get missed during the libp2p updates?

// cc @diasdavid @jacobheun

@olizilla running npm run build and serving dist statically does not produce those errors for me on latest master.

@dryajov I've checked out #1443 locally and can confirm that it fixes the example 👍

With both steps npm start or npm run build && serve dist

@dryajov yes the change to move relay out of experimental was intentional, the example just got missed. The change in js-ipfs was confirmed here at https://github.com/ipfs/js-ipfs/pull/1401#discussion_r198882493

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ntmf picture Ntmf  ·  4Comments

beingmohit picture beingmohit  ·  3Comments

OliverUv picture OliverUv  ·  3Comments

dryajov picture dryajov  ·  3Comments

daviddias picture daviddias  ·  4Comments