waku-org / js-waku

JavaScript implementation of Waku v2
https://js.waku.org
Apache License 2.0
171 stars 42 forks source link

`protons-runtime` dependency not resolving to the latest compatible version #2174

Closed jacobmakarsky closed 1 month ago

jacobmakarsky commented 1 month ago

Error

SyntaxError: The requested module 'protons-runtime' does not provide an export named 'MaxLengthError'

Steps to Reproduce

  1. Install @waku/sdk
  2. Check the installed version of protons-runtime using yarn why protons-runtime.
  3. Observe that the installed version is 5.4.0 instead of the latest compatible version 5.5.0.

Problem

protons-runtime MaxLengthError class is currently used and is introduced in version 5.5.0, but install causes dependency protons-runtime 5.4.0 to be used.

Evidence

0) See protons-runtime version comparison for add of MaxLengthError in latest version: protons-runtime versions comparison: https://github.com/ipfs/protons/compare/protons-runtime-5.4.0...protons-runtime-5.5.0

1) See usage in js-waku packages/proto/package.json: https://github.com/waku-org/js-waku/blob/75fcca4cd99d6aabcbb14afab9332c98ddc6b74f/packages/proto/package.json#L47

2) npm ls protons-runtime produces:

@waku/sdk@0.0.28
  ├─┬ @chainsafe/libp2p-noise@15.1.2
  │ ├─┬ @libp2p/crypto@4.0.4
  │ │ └── protons-runtime@5.4.0
  │ └── protons-runtime@5.2.0
  ├─┬ @libp2p/identify@2.1.5
  │ ├─┬ @libp2p/peer-record@7.0.25
  │ │ └── protons-runtime@5.4.0 deduped
  │ └── protons-runtime@5.4.0
  ├─┬ @libp2p/ping@1.1.6
  │ └─┬ @libp2p/crypto@4.1.9
  │   └── protons-runtime@5.4.0 deduped
  ├─┬ @waku/proto@0.0.8
  │ └── protons-runtime@5.4.0 deduped
  └─┬ libp2p@1.9.4
    ├─┬ @libp2p/peer-id-factory@4.2.4
    │ └── protons-runtime@5.4.0 deduped
    └─┬ @libp2p/peer-store@10.1.5
      └── protons-runtime@5.4.0 deduped

Cause

It seems the @waku/sdk packages is not resolving to latest compatible version of protons-runtime (i.e, 5.5.0 or later) despite using the caret (^) in the version specification. I'm assuming it's because a few packages do not have ^5.4.0, so it defaults to 5.4.0 somehow.

Solution

Maybe patch @chainsafe/libp2p-gossipsub to use ^5.4.0?

Patching like so currently works (for anyone else having the issue): https://github.com/Railgun-Community/waku-broadcaster-client/blob/main/packages/web/patches/%40waku%2Bproto%2B0.0.8.patch

danisharora099 commented 1 month ago

Ah, right, I can confirm that 5.4.0 and 5.5.0 exist:

~/Developer/status/waku master *2 ?1 ❯ npm ls protons-runtime                                                                                      Node 18.20.4 15:22:04
@waku/root@ /Users/danisharora/Developer/status/waku
├─┬ @waku/core@0.0.32 -> ./packages/core
│ └─┬ libp2p@1.8.3
│   └─┬ @libp2p/peer-store@10.1.4
│     └── protons-runtime@5.5.0 deduped
├─┬ @waku/discovery@0.0.5 -> ./packages/discovery
│ └─┬ @libp2p/peer-id-factory@4.2.4
│   └── protons-runtime@5.5.0 deduped
├─┬ @waku/enr@0.0.26 -> ./packages/enr
│ └─┬ @libp2p/crypto@4.1.9
│   └── protons-runtime@5.5.0 deduped
├─┬ @waku/interfaces@0.0.27 -> ./packages/interfaces
│ └─┬ @chainsafe/libp2p-gossipsub@13.1.0
│   └── protons-runtime@5.4.0
├─┬ @waku/proto@0.0.8 -> ./packages/proto
│ ├── protons-runtime@5.5.0
│ └─┬ protons@7.6.0
│   └── protons-runtime@5.5.0 deduped
├─┬ @waku/sdk@0.0.28 -> ./packages/sdk
│ ├─┬ @chainsafe/libp2p-noise@15.1.2
│ │ └── protons-runtime@5.5.0 deduped
│ └─┬ @libp2p/identify@2.1.4
│   ├─┬ @libp2p/peer-record@7.0.24
│   │ └── protons-runtime@5.5.0 deduped
│   └── protons-runtime@5.5.0 deduped
└─┬ @waku/tests@0.0.1 -> ./packages/tests
  └─┬ @libp2p/interface-compliance-tests@5.4.12
    └── protons-runtime@5.5.0 deduped
danisharora099 commented 1 month ago

This should actually be resolved by upgrading chainsafe/libp2p-gossipsub to 14.1.0 -- being done part of https://github.com/waku-org/js-waku/pull/2143 (as it requires other dependencies to be upgraded as well)

cc @weboko we might want to prioritize the libp2p upgrade part of the upcoming release

danisharora099 commented 1 month ago

npm list from the above PR's branch -- no 5.4.0 spotted:

~/Dev/s/waku chore/libp2p-v2 *2 ❯ npm ls protons-runtime
@waku/root@ /Users/danisharora/Developer/status/waku
├─┬ @waku/core@0.0.32 -> ./packages/core
│ └─┬ libp2p@2.1.8
│   └─┬ @libp2p/peer-store@11.0.8
│     └── protons-runtime@5.5.0 deduped
├─┬ @waku/enr@0.0.26 -> ./packages/enr
│ └─┬ @libp2p/crypto@5.0.5
│   └── protons-runtime@5.5.0 deduped
├─┬ @waku/interfaces@0.0.27 -> ./packages/interfaces
│ └─┬ @chainsafe/libp2p-gossipsub@14.1.0
│   └── protons-runtime@5.5.0 deduped
├─┬ @waku/proto@0.0.8 -> ./packages/proto
│ ├── protons-runtime@5.5.0
│ └─┬ protons@7.6.0
│   └── protons-runtime@5.5.0 deduped
├─┬ @waku/sdk@0.0.28 -> ./packages/sdk
│ ├─┬ @chainsafe/libp2p-noise@16.0.0
│ │ └── protons-runtime@5.5.0 deduped
│ └─┬ @libp2p/identify@3.0.8
│   ├─┬ @libp2p/peer-record@8.0.8
│   │ └── protons-runtime@5.5.0 deduped
│   └── protons-runtime@5.5.0 deduped
└─┬ @waku/tests@0.0.1 -> ./packages/tests
  └─┬ @libp2p/interface-compliance-tests@6.1.6
    └── protons-runtime@5.5.0 deduped
jacobmakarsky commented 1 month ago

A developer tagged https://github.com/Railgun-Community/waku-broadcaster-client/blob/main/packages/common/yarn.lock#L6476-L6491 , where the project linked above (the patch file) has a yarn.lock file with 5.4.0. Killing that file and running yarn after fixed and used 5.5.0 in the node modules. Leaving this here in case anyone else runs into the issue.

weboko commented 1 month ago

Seems it's been resolved by re-generating yarn.lock and from js-waku we are going to mitigate it by upgrading libp2p dependencies - https://github.com/waku-org/js-waku/pull/2143