Skip to content
This repository was archived by the owner on Feb 5, 2023. It is now read-only.

Allow custom js-ipfs #5

Merged
merged 14 commits into from
Feb 24, 2020
Merged

Allow custom js-ipfs #5

merged 14 commits into from
Feb 24, 2020

Conversation

icidasset
Copy link
Contributor

@icidasset icidasset commented Feb 15, 2020

Adds the option:

jsIpfs: "https://unpkg.com/ipfs@latest/dist/index.min.js" // Default
jsIpfs: async () => await import("ipfs")
jsIpfs: () => Promise.resolve(Ipfs)

@icidasset icidasset added the 💗 enhancement New feature or request label Feb 15, 2020
@icidasset icidasset requested a review from dholms February 19, 2020 18:00
src/get-ipfs.ts Outdated

if (!ipfsPkg?.create) return null
const peers = (config.peers || []).concat(config.browserPeers || [])
const ipfs = await ipfsPkg.create({ config: { Addresses: { Swarm: peers }}})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work? I tried locally and got Error: no valid addresses were provided for transports [WebSockets,WebRTCStar,Circuit]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm getting this error as well. That's what I'm trying to figure out with the new js-ipfs. This used to work, see our Fission Drive code: https://github.com/fission-suite/drive/blob/22468f5908b7715bf516c87debf05ae36c974588/src/Javascript/ipfs.js#L32-L34

Could it be something regarding "delegated routing" which they excluded now? https://blog.ipfs.io/2020-02-13-js-ipfs-0-41/ (search for "Delegated peer and content routing")

Are we doing delegated routing with us passing the peer id in the multiaddr? (eg. /dns4/node.fission.systems/tcp/4003/wss/ipfs/QmVLEz2SxoNiFnuyLpbXsH6SvjPTrHNMU88vCQZyhgBzgw)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I... don't think so? Not very familiar with that. But delegated routing seems to be "okay I have this peer id, but not the full multiaddr, can you connect me?"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's actually surprising to me that that worked in the Fission Drive code. I thought I remembered trying this back when originally making this lib and it not working. I either had to use ipfs.swarm.connect() or put the addresses in config.Bootstrap

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh weird. Ok, I'll do some more digging because this is all very confusing 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome thanks 👍 I did notice you added a tries: number param, but never used it. Do you want me to implement this? Also, no timeout/delay between retries?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick code edits squeezed in before team meetings come back to bite me 😛

Yes I'll fix that haha

And the timeout doesn't seem to be necessary. It either requires multiple connect attempts or a timeout of about 200ms 🤷‍♂️

I'll add it as an additional param though in case we want to use it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😬 😄 Ok cool. So weird these connection issues.

One last thing, I'm getting an error on safari when using the latest js-ipfs. Could you check if you get that too with ipfs-user-settings? 🙏 I'm getting a timeoutController.clear is not a function error. Made an issue for that on the libp2p repo, but trying to get more info.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay pushed the new code 👍

I'm on linux so unfortunately don't have Safari 😬 but I don't get any such error in FF/Chrome

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right. Carry on! 😬 😅

@icidasset
Copy link
Contributor Author

@dholms How do I use this semantic-release thing you've setup? Are we generating a changelog based on the git commits using this?

@dholms
Copy link
Collaborator

dholms commented Feb 21, 2020

ah semantic-release is actually left over from the boilerplate I used to set this library up. It included some tooling that we haven't been using. I did get rid of it with our typescript-boilerplate library

So yeah just ignore it for now. There's a little more cleanup I need to do on the tooling as well. I'll make an issue for it

@icidasset
Copy link
Contributor Author

Cool, sounds good 👍 I've bumped the version and added a changelog.

Copy link
Collaborator

@dholms dholms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright I'm gonna give this an approval because it seems like this is working for both of us with the retry logic.

If you could take a quick look at the code I added before merging, that'd be great 👍

I'm also going to create a separate issue about the AggregateError for further review, but I don't think that needs to block us from merging this

@icidasset icidasset merged commit 9ac5dbd into master Feb 24, 2020
@icidasset icidasset deleted the custom-url branch February 24, 2020 21:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
💗 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants