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

Setting a cookie in Next.js in a server action causes a Hydrate warning and wagmi stays in "reconnecting" #3629

Closed
1 task done
smauret opened this issue Feb 23, 2024 · 2 comments

Comments

@smauret
Copy link

smauret commented Feb 23, 2024

Describe the bug

When a server action sets a cookie with cookies().set("myCookie", "value") and wagmi is setup using a cookie store, then after the action has been performed, a warning is thrown and wagmi is stuck in reconnecting status:

Warning: Cannot update a component (`Page`) while rendering a different component (`Hydrate`). To locate the bad setState() call inside `Hydrate`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render
    at Hydrate (webpack-internal:///(app-pages-browser)/./node_modules/wagmi/dist/esm/hydrate.js:12:13)
    at WagmiProvider (webpack-internal:///(app-pages-browser)/./node_modules/wagmi/dist/esm/context.js:13:13)
    at Providers (webpack-internal:///(app-pages-browser)/./app/providers.tsx:39:11)
    at body
    at html

The only way to get wagmi to reconnect is to refresh the page.

I have created a repo with minimum setup to reproduce.

Link to Minimal Reproducible Example

https://github.com/smauret/wagmi-next-bug-repro

Steps To Reproduce

  1. Setup wagmi with a cookie store
  2. Trigger a server action that sets a cookie
  3. See warning in browser console + wagmi account status stays "reconnecting"

Wagmi Version

2.5.7

Viem Version

2.7.3

TypeScript Version

5.3.3

Check existing issues

Anything else?

There are a couple of similar issues, and they might all be related, but this issue specifically uses the wagmi cookie store and setting cookies.
The cookie setup is slightly different than in the docs because I use rainbowkit (explanation here) and I don't believe that is an issue.

@jxom
Copy link
Member

jxom commented Mar 18, 2024

Fixed

@jxom jxom closed this as completed Mar 18, 2024
Copy link
Contributor

github-actions bot commented Apr 2, 2024

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 other comments you can create a new discussion.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 2, 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