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

EIP-1193 auto-injected connector connections don't persist on page refresh if previously disconnected with ssr enabled #4195

Closed
1 task done
kristiegiles opened this issue Aug 7, 2024 · 2 comments

Comments

@kristiegiles
Copy link
Contributor

Check existing issues

Describe the bug

When connecting with WalletConnect, the connection reliably persists when you refresh the page. However, if you connect with MetaMask or another wallet via the EIP-1193 auto-injected connector, you get disconnected on page refresh if you have previously disconnected via disconnectAsync from useDisconnect.

It seems the ssr cookies like wagmi.io.metamask.disconnected: true are set on disconnect:

Screenshot 2024-08-07 at 11 01 05 AM

And they are not removed or set to wagmi.io.metamask.disconnected: false when you reconnect via connectAsync from useConnect. If you manually delete these cookies after reconnecting, you will no longer be logged out on refresh.

It seems like it may be best for wagmi to handle deleting these cookies or setting them to false on connect.

I removed the following ssr configuration from my config, and that fixed the issue:

  ssr: true,
  storage: createStorage({
    storage: cookieStorage,
  }),

Link to Minimal Reproducible Example

No response

Steps To Reproduce

No response

What Wagmi package(s) are you using?

wagmi

Wagmi Package(s) Version(s)

2.10.9

Viem Version

2.17.3

TypeScript Version

5.1.3

Anything else?

Relevant part of connector config:

const config = createConfig({
  ssr: true,
  chains: [mainnet, sepolia ],
  storage: createStorage({
    storage: cookieStorage,
  }),
  ...
})

Using React 18.3.1, Next.js 13.4.19, Turborepo, Bun

@tmm
Copy link
Member

tmm commented Aug 7, 2024

Try upgrading to the latest Wagmi version. Might be related to #4097, which was fixed yesterday.

@tmm tmm closed this as not planned Won't fix, can't repro, duplicate, stale Aug 7, 2024
Copy link
Contributor

This issue has been locked since it has been closed for more than 14 days.

If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Wagmi version. If you have any questions or comments you can create a new discussion thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants