-
Notifications
You must be signed in to change notification settings - Fork 12
fix: accept http client instance #39
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f847187
fix: accept http client instance
achingbrain 7115adf
chore: demand client instance
achingbrain d0e30a2
chore: update node versions
achingbrain 8f9bc5b
chore: update readme
achingbrain 83000cf
chore: restore peer deps
achingbrain 7016c4a
chore: update README.md
jacobheun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,8 @@ stages: | |
- cov | ||
|
||
node_js: | ||
- '10' | ||
- '12' | ||
- 'lts/*' | ||
- 'node' | ||
|
||
os: | ||
- linux | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,23 +22,26 @@ | |
"coverage": "aegir coverage" | ||
}, | ||
"devDependencies": { | ||
"aegir": "^25.0.0", | ||
"aegir": "^26.0.0", | ||
"go-ipfs": "0.6.0", | ||
"ipfs-http-client": "^45.0.0", | ||
"ipfs-utils": "^2.2.0", | ||
"ipfsd-ctl": "^5.0.0", | ||
"ipfs-http-client": "^46.0.0", | ||
"ipfs-utils": "^3.0.0", | ||
"ipfsd-ctl": "^7.0.0", | ||
"it-all": "^1.0.2" | ||
}, | ||
"peerDependencies": { | ||
"ipfs-http-client": "^44.0.0" | ||
}, | ||
"dependencies": { | ||
"cids": "^1.0.0", | ||
"debug": "^4.1.1", | ||
"p-defer": "^3.0.0", | ||
"p-queue": "^6.3.0", | ||
"peer-id": "^0.14.0" | ||
}, | ||
"peerDependencies": { | ||
"ipfs-http-client": "^46.0.0" | ||
}, | ||
"browser": { | ||
"go-ipfs": false | ||
}, | ||
"contributors": [ | ||
"Jacob Heun <[email protected]>", | ||
"Alex Potsides <[email protected]>", | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the hoist problem ipfs is hitting? The
ipfs-http-client
is still a peer dependency as they have to be installed together to work properly. Is this a problem with major version changes of the api still working with this module?I assume this is something like: when
ipfs-http-client@47
needs to be released, this module has to be updated for IPFS, but it requires this module to be released with the "unreleased" client version that's not ready yet?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hoisting problem is that
libp2p-delegated-*
end up installed in/node_modules
- they try torequire('ipfs-http-client')
but there's no/node_modules/ipfs-http-client
as they do not declare a runtime dep so none is installed. There is a symlink from/packages/ipfs/node_modules/ipfs-http-client
to/packages/ipfs-http-client
however (the actual peer dep), so we addlibp2p-delegated-*
to thenohoist
list which installs them at/packages/ipfs/node_modules
instead.This allows them to
require('ipfs-http-client')
but also means their dependencies are not hoisted either, so there's a duplicatepeer-id
module (for example) under/packages/ipfs/node_modules/libp2p-delegated-peer-routing/node_modules/peer-id
which is the same version as the hoisted/node_modules/peer-id
which is used by everything else in the stack.This is primarily a dev problem and not something that occurs when people are using
ipfs
in their own projects, so I'd be inclined to ignore it and mentally make a note to PR lerna to symlink peer dependencies during hoisting, but the peer dependency thing doesn't really guarantee that you'll get the version you want so it's not safe and the versions lag often, printing warning messages when installing ipfs that confuse people and show that in actual fact these modules are not getting the version they want.Since these modules also do deep requires into the internals of the http client, it prevents refactoring those internals without either releasing a major or otherwise inadvertently breaking the delegate modules. Now they depend only on the core-api which we hope is more stable over time.
The release dance is another problem, yes.
All in all it's a bit of a code smell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing in a client makes complete sense to me and I'm in favor of that change.
For the peerDependency, one of the pain points we've been trying to work around with libp2p is declaring version matching with js-libp2p in particular. We encounter issues quite often where users are using versions of modules that don't work with the version of libp2p they're using.
peerDependencies
is a reasonable method for us to be able to declare that. Another option is to just declare this in the docs, but that is more prone to getting stale.If we moved away from caret semver to range semver for peerDependencies this could avoid the warning for end users.
"ipfs-http-client": ">=44.0.0"
would allow for any future versions of the http client to not log warnings, and we would only need to update it when a breaking change occurs that affects this module. The warning will still happen for pre releases, because they don't apply to normal semver, but final releases wouldn't have the issue.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a hard problem to solve.
Marking the peer dep as
>=44.0.0
will hide the 'you need to install a peer dep' warning but it makes no guarantee that45.0.0
won't remove the.dht
methods, for example.You could use feature detection to ensure the right methods were present, but even then if the internal implementation is incompatible for whatever reason (e.g. different deps, or whatever) it could still explode at runtime.