-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
wagmi stays in the reconnecting: true
state during the hot-reload
#3490
Comments
Any luck with this im getting a smiliar error where I have to reconnect my wallet every hot reload? |
I've debugged a little bit and think that the issue is that the I'm not that great in Export-1705841309505.mp4wagmi/packages/react/src/hydrate.ts Lines 12 to 36 in ace8acf
|
Your issue is a bit different I believe, make sure you're persisting wagmi state via cookies https://wagmi.sh/react/guides/ssr#persistence-using-cookies |
I was able to modify the script the next way and now export function Hydrate(parameters: React.PropsWithChildren<HydrateProps>) {
const { children, config, initialState, reconnectOnMount = true } = parameters
const { onMount } = hydrate(config, {
initialState,
reconnectOnMount,
})
// Hydrate for non-SSR
if (!config._internal.ssr) onMount()
// biome-ignore lint/nursery/useExhaustiveDependencies:
useEffect(() => {
if (!config._internal.ssr) return
onMount()
}, [onMount])
return children as ReactElement
} As far as I've understood, the However, I think the effect still has to be run as during hot-reload component might get re-mounted. Using this as a workaround for now. |
As far as I've understood, the `const active = useRef(true)` was there to really make sure the effect is run just once as React doesn't guarantee that an effect won't be re-run once again, and for the same reason the dependencies were empty to minimize the redundant effect calls. However, I think the effect still has to be run as during hot-reload component might get remounted with all connectors hanging in `isReconnecting: true` state. Using this as a workaround for now. Might fix wevm#3490, yet also prune to excessive re-connects that might cause UI regressions, idk.
#3492 also fixes revalidate rerender issue that was mentioned in the "Anything else?" block. |
Hello, I'm getting that behaviour too, trying to do a web3 action after hot reload fails with |
I have exactly same issue. Have you fixed it? |
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. |
Describe the bug
When you're making any changes in nextjs routes, the app tries to hot reload and wagmi hands at the
isReconnecting: true
state:Export-1705764560181.mp4
Link to Minimal Reproducible Example
https://github.com/dalechyn/mini-repros/tree/main/wagmi-hot-reload-infinite-reconnect
Steps To Reproduce
pnpm dev
src/app/revalidate/route.ts
and make any change thereWagmi Version
2.3.1
Viem Version
2.4.0
TypeScript Version
5.2.2
Check existing issues
Anything else?
Originally a similar bug (which I believe has a common root with issue) happened to me when I have used trpc's experimental app router library's
revalidate
method that revalidates a route bytag
.The same effect was achieved, yet I was not able to achieve the same effect with this repro outside of hot-reload, but when a revalidation happens from the server-side, wagmi suffers from the same reconnect hanging issue:
Export-1705765355451.mp4
Reference scrapped out code:
The text was updated successfully, but these errors were encountered: