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

chore: throw error no swarm on multiaddrs using websocket-star #3051

Merged

Conversation

vasco-santos
Copy link
Member

On [email protected], we removed the websocket-star module from the libp2p default configuration for browser nodes in js-ipfs. We removed it because this module was not refactored during #1670, since the libp2p goal is to sunset the star protocols and we preferred to use the time refactoring websocket-star into improving the browser support.

In the refactor, the webrtc-star module was refactored so that browser users could discover other peers in the network. In addition, circuit-relay may be used for establishing connections between browser nodes using websockets.

However, this migration has not been smooth for js-ipfs users. Users previously using websocket-star swarm addresses, did not have enough visibility of this change, since the removal of websocket-star was transparent for them and on the default js-ipfs release and not technically a programmable breaking change.

With the above in mind, once js-ipfs users updated they started getting errors from js-libp2p in scenarios where they were providing only websocket-star swarm addresses. When js-libp2p receives listening multiaddrs, it throws an error if it cannot use any to listen on the configured transports, which was the case here (For instance #2779).

In js-libp2p, we added an option to tolerate these errors libp2p/js-libp2p#643, which was also mentioned for some other cases earlier.

After syncing about this issue, we decided to temporarily throw an error when js-ipfs receives websocket-star multiaddrs. This aims to help users who still need to migrate to identify the problem faster.

@vasco-santos vasco-santos requested a review from achingbrain May 27, 2020 12:27
try {
await node.start()
} catch (err) {
expect(err).to.exist()
Copy link
Member

Choose a reason for hiding this comment

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

Please assert the correct error was thrown.

Better yet, do something like

await expect(node.start()).to.eventually.be.rejectedWith(/regex to use on error message/)

or

await expect(node.start()).to.eventually.be.rejected().with.property('code', 'ERR_SOME_CODE')

then you don't need the try/catch and the following throw.

@@ -130,7 +138,6 @@ module.exports = ({
apiManager.update(api, () => undefined)
} catch (err) {
cancel()
startPromise.reject(err)
Copy link
Member

Choose a reason for hiding this comment

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

Why did this get removed? If the user calls node.start() twice, the second promise will never resolve/reject.

I'm not sure how common this is, but I'd like to re-evaluate the use of the api proxy as part of #2762.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, I did not understand that this was used to restart.

So, what happens with the startPromise.reject(err) is that this promise rejection is not being handled anywhere. I looked closely on this now, and it seems that the ApiManager should take care of handling promise rejections. Is that fair to assume? I am not sure on how to actually do this though.

Copy link
Member

Choose a reason for hiding this comment

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

It's not used to restart, it's if the user calls node.start() on a node that's already starting up.

Copy link
Member Author

Choose a reason for hiding this comment

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

sorry, I understood, but misspelled it: parallel starts

So, how to you think we should go on handling the promise rejections on the APIManager

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a catch, but I am not sure this is the best approach here. Let me know

@vasco-santos vasco-santos force-pushed the chore/thrown-error-on-swarm-multiaddrs-using-websocket-star branch from 0a92322 to f8d1c80 Compare June 12, 2020 09:07
@vasco-santos vasco-santos requested a review from achingbrain June 12, 2020 12:36
@achingbrain achingbrain merged commit b9db5d4 into master Jun 22, 2020
@achingbrain achingbrain deleted the chore/thrown-error-on-swarm-multiaddrs-using-websocket-star branch June 22, 2020 15:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants