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

a disconnect error by default value or other reason can not set local storage #2227

Closed
1 task done
logsdk opened this issue Jun 10, 2024 · 13 comments · Fixed by #2236
Closed
1 task done

a disconnect error by default value or other reason can not set local storage #2227

logsdk opened this issue Jun 10, 2024 · 13 comments · Fixed by #2236
Assignees
Labels
bug Something isn't working

Comments

@logsdk
Copy link

logsdk commented Jun 10, 2024

Current Behavior

1、connect wallet, tips successful
2、discount wallet, error

SyntaxError: Unexpected end of JSON input
at JSON.parse ()
at disconnect (index-34745058.js:3597:25)
at async eval (useConnectWallet.js:25:29)

in packages/core/src/disconnect.ts:47

const labels = JSON.parse(getLocalStore(STORAGE_KEYS.LAST_CONNECTED_WALLET) || '');

if can not get last connected wallet, the default value '', can not be parsed by JSON.

Expected Behavior

disconnect wallet successful

Steps To Reproduce

No response

What package is effected by this issue?

@web3-onboard/core

Is this a build or a runtime issue?

Runtime

Package Version

2.22.1

Node Version

No response

What browsers are you seeing the problem on?

No response

Relevant log output

No response

Anything else?

No response

Sanity Check

  • If this is a build issue, I have included my build config. If this is a runtime issue, I have included reproduction steps and/or a Minimal, Reproducible Example.
@logsdk logsdk added the bug Something isn't working label Jun 10, 2024
@Adamj1232
Copy link
Member

Hi @logsdk can you provide more context for me around what this code is trying to do?

@ignromanov
Copy link

Hi.
The same issue.
You need to connect to the DApp using Rabby wallet.
After pressing the disconnect button (calling the disconnect function) - an error is thrown.

  const [{ wallet }, disconnect] = useConnectWallet()
  await disconnect(wallet)

The reason is that the onboard.js:last_connected_wallet key is missing from the local storage

@Adamj1232
Copy link
Member

@ignromanov Disconnect using the approach as shown above working without issue on our demo sites - https://github.com/blocknative/react-demo/blob/89509379f4cd09299b45b2301769aa80a7c58991/src/App.js#L543
If you can provide more code for context I can assist further

@ignromanov
Copy link

The reason was that flags autoConnectLastWallet and autoConnectAllPreviousWallet were false during onboard initialization

@Adamj1232
Copy link
Member

@ignromanov does that mean we can close this issue?

@ignromanov
Copy link

@Adamj1232 I think you should test with these flags set to False. You will get a disconnect error.

@Adamj1232
Copy link
Member

@ignromanov I am still unable to reproduce the disconnect error - I made a video of what I am seeing when trying this locally. https://www.loom.com/share/3d73a7ccfa1645cb9deb820fb8ea438c?sid=93f5efb4-5539-4075-a204-c9ea9dcea605
Might be good to confirm you are on the latest version of "@web3-onboard/injected-wallets": "^2.11.1"

@ignromanov
Copy link

@Adamj1232 I tried it on your test application. Try with these changes to reproduce it. I got an error.

image

@Adamj1232
Copy link
Member

@ignromanov I am still unable to reproduce an error with that change

@ignromanov
Copy link

@Adamj1232 Recorded a video reproduction of the error. Launched your repository with the change described above.

Screen.Recording.2024-06-14.at.22.53.38.mov

@satoshisafedevs
Copy link

We are seeing this same issue with the latest version on all packages and brave browser.

@Adamj1232
Copy link
Member

@ignromanov ahh ok I think I got it figured out, required a local storage clear to reproduce. Looking into this today. Will have a fix shortly.

@Adamj1232
Copy link
Member

@ignromanov please give this a shot with the latest alpha version of @web3-onboard/core or framework package noted in the PR above - would love validation on your end prior to release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
5 participants