anza-xyz / wallet-adapter

Modular TypeScript wallet adapters and components for Solana applications.
https://anza-xyz.github.io/wallet-adapter/
Apache License 2.0
1.44k stars 906 forks source link

TransportRaceCondition in ledger-transport.js changed to TransportPendingOperation #950

Open infoparth opened 2 months ago

infoparth commented 2 months ago

Error: No matching export in "node_modules/@ledgerhq/errors/lib-es/index.js" for import "TransportRaceCondition"

node_modules/@solana/wallet-adapter-ledger/node_modules/@ledgerhq/hw-transport/lib-es/Transport.js:74:9:
  74 │ import { TransportRaceCondition, TransportError, StatusCodes, getAltStatusMessage, Transp...

which is causing the application to break on running "npm run dev",

because TransportRaceCondition has been updated to TransportPendingOperation, as mentioned here https://github.com/LedgerHQ/ledger-live/commit/931d511f5c5da86ddee53c69775515da019b6241

swapping TransportRaceCondition with TransportPendingOperation in the node modules worked for me, but it might break the application in production.

jesulonimii commented 2 months ago

Hey. noticed this issue also. A work around I implemented was to modify the @ledgerhq/errors package from @ledgerhq/errors@6.16.4 to @ledgerhq/errors@6.16.3 in my package-lock.json. (and sha256 signature also)

So it uses the previous working version, pending the time this is resolved

infoparth commented 2 months ago

Hey. noticed this issue also. A work around I implemented was to modify the @ledgerhq/errors package from @ledgerhq/errors@6.16.4 to @ledgerhq/errors@6.16.3 in my package-lock.json. (and sha256 signature also)

So it uses the previous working version, pending the time this is resolved

Hey @jesulonimii , thanks a lot for the help... it saved me

wakechromium commented 2 months ago

Hey. noticed this issue also. A work around I implemented was to modify the @ledgerhq/errors package from @ledgerhq/errors@6.16.4 to @ledgerhq/errors@6.16.3 in my package-lock.json. (and sha256 signature also)

So it uses the previous working version, pending the time this is resolved

Getting same error but enable to resolve.

sunfkny commented 2 months ago

Hey. noticed this issue also. A work around I implemented was to modify the @ledgerhq/errors package from @ledgerhq/errors@6.16.4 to @ledgerhq/errors@6.16.3 in my package-lock.json. (and sha256 signature also)

So it uses the previous working version, pending the time this is resolved

@jesulonimii A better way is to add overrides in the package.json file of your project. #949

shawalali07 commented 2 months ago

Hey. noticed this issue also. A work around I implemented was to modify the @ledgerhq/errors package from @ledgerhq/errors@6.16.4 to @ledgerhq/errors@6.16.3 in my package-lock.json. (and sha256 signature also)

So it uses the previous working version, pending the time this is resolved

Can you share the exact change here?

mrsaifullah52 commented 2 months ago

after down grade the version it throws another error:

✘ [ERROR] No matching export in "node_modules/@ledgerhq/hw-transport/node_modules/@ledgerhq/errors/lib-es/index.js" for import "TransportPendingOperation"

    node_modules/@ledgerhq/hw-transport/lib-es/Transport.js:11:9:
      11 │ import { TransportPendingOperation, TransportError, StatusCodes, getAltStatusMessage, TransportStatusError, } from "@ledgerhq/errors";
mcintyre94 commented 1 month ago

Can someone please provide source code that produces an error here?

I've updated the example app to include new LedgerWalletAdapter(), and I'm able to connect to a ledger wallet with no issues

I'd like to understand this error more before figuring out how we want to fix it here. Also note that TransportRaceCondition is not found in the source code of wallet-adapter, so I'm not sure yet where this error is coming from.

mcintyre94 commented 1 month ago

I'm going to move discussion here from #949 which is a closed PR

Thanks to https://github.com/sponge-babe we have a repro using yarn: https://github.com/sponge-babe/ledgerhq-issue

I can repro with yarn & yarn start in that repo.

If I add resolutions like this:

"resolutions": {
    "@ledgerhq/errors": "6.16.3"
},

Then there's a warning from yarn:

warning Resolution field "@ledgerhq/errors@6.16.3" is incompatible with requested version "@ledgerhq/errors@^6.16.4"

But it does seem to resolve to 6.16.3:

"@ledgerhq/errors@6.16.3", "@ledgerhq/errors@^6.10.0", "@ledgerhq/errors@^6.16.4":
  version "6.16.3"
  resolved "https://registry.yarnpkg.com/@ledgerhq/errors/-/errors-6.16.3.tgz#646f68cc7e6e8d5126bce1ca06140c5ad963bee8"
  integrity sha512-3w7/SJVXOPa9mpzyll7VKoKnGwDD3BzWgN1Nom8byR40DiQvOKjHX+kKQausCedTHVNBn9euzPCNsftZ9+mxfw==

But I still get the error when it starts:

ERROR in ./node_modules/@ledgerhq/hw-transport-webhid/node_modules/@ledgerhq/hw-transport/lib-es/Transport.js 242:18-43

Now if I search @ledgerhq/hw-transport in the yarn lock file it seems to be resolving two versions:

"@ledgerhq/hw-transport@6.27.1":
  version "6.27.1"
  resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport/-/hw-transport-6.27.1.tgz#88072278f69c279cb6569352acd4ae2fec33ace3"
  integrity sha512-hnE4/Fq1YzQI4PA1W0H8tCkI99R3UWDb3pJeZd6/Xs4Qw/q1uiQO+vNLC6KIPPhK0IajUfuI/P2jk0qWcMsuAQ==
  dependencies:
    "@ledgerhq/devices" "^6.27.1"
    "@ledgerhq/errors" "^6.10.0"
    events "^3.3.0"

"@ledgerhq/hw-transport@^6.27.1":
  version "6.30.6"
  resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport/-/hw-transport-6.30.6.tgz#c6d84672ac4828f311831998f4101ea205215a6d"
  integrity sha512-fT0Z4IywiuJuZrZE/+W0blkV5UCotDPFTYKLkKCLzYzuE6javva7D/ajRaIeR+hZ4kTmKF4EqnsmDCXwElez+w==
  dependencies:
    "@ledgerhq/devices" "^8.3.0"
    "@ledgerhq/errors" "^6.16.4"
    "@ledgerhq/logs" "^6.12.0"
    events "^3.3.0"

If I instead add the resolution:

"resolutions": {
    "@ledgerhq/hw-transport": "6.27.1"
},

Then that fixes the issue. So as a workaround for everyone seeing this, this resolution is probably the best solution.

I'm a bit stumped though, because we have that resolution: https://github.com/anza-xyz/wallet-adapter/blob/8748ff507b61eaf65e06439fe4bc5fb27e48f70c/package.json#L63

We also have that precise version as the dependency of the ledger adapter: https://github.com/anza-xyz/wallet-adapter/blob/8748ff507b61eaf65e06439fe4bc5fb27e48f70c/packages/wallets/ledger/package.json#L39

So I'm not sure how yarn is messing this up TBH, or what we can do to fix this for you in our code. I'm not really familiar with yarn though, so would be keen to hear any ideas.

Also, has anyone seen this with any package manager other than Yarn?

sponge-babe commented 1 month ago

"resolutions": { "@ledgerhq/hw-transport": "6.27.1" },

i tried your solution in the same repo, and it didn't work. how did you make it work with: "resolutions": { "@ledgerhq/hw-transport": "6.27.1" }

TechTronixx commented 1 month ago

I've managed to find a workaround fix based on previous suggestions, which is currently working with pnpm, & yarn. There are no issues with Vite either.

I'm using React v18.2.0. Adding the following seems to be working at the moment :

"resolutions": {
  "@ledgerhq/devices": "6.27.1",
  "@ledgerhq/errors": "6.16.3",
  "@ledgerhq/hw-transport": "6.27.1",
  "@ledgerhq/hw-transport-webhid": "6.27.1"
}
sponge-babe commented 1 month ago

I've managed to find a workaround fix based on previous suggestions, which is currently working with npm, pnpm, & yarn. There are no issues with Vite either.

I'm using React v18.2.0. Adding the following seems to be working at the moment :

"resolutions": { "@ledgerhq/devices": "6.27.1", "@ledgerhq/errors": "6.16.3", "@ledgerhq/hw-transport": "6.27.1", "@ledgerhq/hw-transport-webhid": "6.27.1" }

This solution worked! Thanks @TechTronixx

redcomethk commented 1 month ago

I've managed to find a workaround fix based on previous suggestions, which is currently working with npm, pnpm, & yarn. There are no issues with Vite either.

I'm using React v18.2.0. Adding the following seems to be working at the moment :

"resolutions": { "@ledgerhq/devices": "6.27.1", "@ledgerhq/errors": "6.16.3", "@ledgerhq/hw-transport": "6.27.1", "@ledgerhq/hw-transport-webhid": "6.27.1" }

It seems some small tweaking is needed for npm as "overrides" is supported instead of "resolutions" I have added this to my package.json and it works:

"overrides": {
  "@ledgerhq/devices": "6.27.1",
  "@ledgerhq/errors": "6.16.3",
  "@ledgerhq/hw-transport": "6.27.1",
  "@ledgerhq/hw-transport-webhid": "6.27.1"
}