Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Example: Circuit Realying broken #1423

Closed
0x-r4bbit opened this issue Jul 5, 2018 · 15 comments
Closed

Example: Circuit Realying broken #1423

0x-r4bbit opened this issue Jul 5, 2018 · 15 comments
Labels
exp/expert Having worked on the specific codebase is important kind/bug A bug in existing code (including security flaws) P3 Low: Not priority right now

Comments

@0x-r4bbit
Copy link
Contributor

Type: Bug

Severity: Medium

Description:

At the time of creating this issue (latest master c1ee247), 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
@alanshaw alanshaw added kind/bug A bug in existing code (including security flaws) exp/expert Having worked on the specific codebase is important status/ready Ready to be worked P3 Low: Not priority right now labels Jul 6, 2018
@victorb
Copy link
Member

victorb commented Jul 12, 2018

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

@victorb
Copy link
Member

victorb commented Jul 12, 2018

Seems Alan actually fixed it and it's in master now: a08a17d

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

@alanshaw
Copy link
Member

@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!

@0x-r4bbit
Copy link
Contributor Author

Verifying this now.

@0x-r4bbit
Copy link
Contributor Author

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 

@0x-r4bbit
Copy link
Contributor Author

@victorbjelkholm can you confirm this? ^

@olizilla
Copy link
Member

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

@olizilla
Copy link
Member

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.

@0x-r4bbit
Copy link
Contributor Author

Thanks @olizilla let me know if you need any help

@olizilla
Copy link
Member

olizilla commented Jul 16, 2018

@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!

@0x-r4bbit
Copy link
Contributor Author

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 ?

@olizilla
Copy link
Member

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.

@dryajov
Copy link
Member

dryajov commented Jul 16, 2018

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 - #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

@0x-r4bbit
Copy link
Contributor Author

@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

@jacobheun
Copy link
Contributor

@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 #1401 (comment)

@ghost ghost removed the status/ready Ready to be worked label Jul 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
exp/expert Having worked on the specific codebase is important kind/bug A bug in existing code (including security flaws) P3 Low: Not priority right now
Projects
None yet
Development

No branches or pull requests

6 participants