wallet-adapter: Updating `WalletProvider.onError` prop incorrectly disconnects the adapter

Describe the bug I am using the wallet adapter in React, with Phantom wallet. I am passing in the endpoint value as a prop.

I recently upgraded from 0.9.5 to 0.9.18, and now, when I change/set the RPC value in react, the wallet disconnects.

I tried to narrow it down to a more specific version to find the commit that introduced the bug but I couldn’t get npm to install the older versions without using my old lock file.

If I downgrade back to 0.9.5 and my old lock file, changing the RPC lets the wallet remain connected.

Some additional things I noticed if it helps:

On the working version, it looks like the wallet state just changes once. In the current version, I see it change state twice after swapping RPC.

Possibly helpful state values after changing rpc:

0.9.5:

autoConnect: true
connected: true
connecting: false
disconnecting: false
readyState: "Installed'
publicKey: defined

0.9.18:

autoConnect: true
connected: false
connecting: false
disconnecting: false
readyState: 'Installed'
publicKey: null

To Reproduce Steps to reproduce the behavior:

  1. Setup simple react ui app doing something like logging the users public key
  2. Use react variable for endpoint prop
  3. Change endpoint on action, e.g. clicking a button
  4. Wallet will disconnect and public key is no longer available for logging

Expected behavior Wallet stays connected if previously connected

Screenshots

https://user-images.githubusercontent.com/22151537/198815343-205bcad1-7523-4ca7-ac7e-25a138efdd57.mp4

Desktop (please complete the following information):

  • OS: gahnoo loonix
  • Browser: Firefox
  • Version: 106.0.1

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 30

Commits related to this issue

Most upvoted comments

Thanks for this! Wrote a test so that this doesn’t happen again: 2c17fc69e6934588cb4491d5bed1017571f9ae0b.