Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dial protocol should throw if no protocol is provided #914

Merged

Conversation

vasco-santos
Copy link
Member

This makes ts projects using dialProtocol to have to validate wether a stream pair object or a connection is returned. Moreover, returning different types conditionally is not really a good practise.

We should consider in the future to just deprecate dialProtocol as users can now easily open streams from a given connection

BREAKING CHANGE: dialProtocol does not return connection when no protocols are provided

BREAKING CHANGE: dialProtocol does not return connection when no protocols are provided
Copy link
Member

@achingbrain achingbrain left a comment

Choose a reason for hiding this comment

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

LGTM

src/index.js Outdated
*
* @async
* @param {PeerId|Multiaddr|string} peer - The peer to dial
* @param {string[]|string} protocols
* @param {object} [options]
* @param {AbortSignal} [options.signal]
* @returns {Promise<Connection|{ stream: MuxedStream; protocol: string; }>}
* @returns {Promise<{ stream: MuxedStream; protocol: string; }>}
Copy link
Member

Choose a reason for hiding this comment

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

Could remove the @returns annotation altogether?

src/index.js Outdated Show resolved Hide resolved
@vasco-santos vasco-santos merged commit 21c9aee into master Apr 16, 2021
@vasco-santos vasco-santos deleted the fix/dial-protocol-should-throw-if-no-protocol-provided branch April 16, 2021 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants