-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
useAccountEffect.onConnect not called after some page reloads #4221
Comments
Similar issue in our https://www.ustc.plus/ |
We are also having this issue on https://nfts2me.com/app/ After some digging, we've seen that the issue comes from WalletConnect and wallets that use it, like Wagmi should be able to handle a delay from WalletConnect servers response and ignore its response until it responds, not affecting the rest of the connectors for wallets. It seems that the WS requests to No idea why it doesn't happen on the first connect, and only after a reconnection. We've disabled temporarily those wallets to make it work. |
Seems to be working fine to me now. If anyone is still experiencing this, please reply with a video so I can clearly see your reproduction steps. (If this comes up again in the future and this current issue is locked, feel free to create a new issue referencing this one.) |
Can still reproduce in wagmi@2.12.14
function App() {
useAccountEffect({
onConnect: (data) => console.log('useAccountEffect', data),
});
const config = useConfig();
useEffect(() => {
return watchAccount(config, {
onChange(data, prevData) {
console.log('debug watchAccount onChange', { prevData, data });
},
});
}, [config]);
screen-recording.webmtimestamps: |
@lukaw3d looks like the video isn’t there |
converted webm to mp4. Does this work https://github.com/user-attachments/assets/3c5b1240-ac60-4e13-bcea-4f24880188b4? b.mp4or gif: https://github.com/user-attachments/assets/1062e38c-32d5-4a3c-b5cc-c872868aaabe |
Thanks for attaching! Was able to reproduce. Since most folks likely have Site access set to "On all sites" (it's the default), not sure it's worth updating the behavior at this moment to accommodate "On click" as other features, like chain switching, also do not work with this setting. Let's treat this as more of a feature request for future support (converting to discussion). In the meantime, to patch if (
(prevData.status === 'reconnecting' ||
- (prevData.status === 'connecting' &&
- prevData.address === undefined)) &&
+ prevData.status === 'connecting') &&
data.status === 'connected'
) { |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Check existing issues
Describe the bug
I'm trying to consistently listen to onConnect
but it isn't triggered when reloading the page by enabling metamask to run on the site
Link to Minimal Reproducible Example
https://stackblitz.com/edit/new-wagmi-tfvypz?file=src%2FApp.tsx
Steps To Reproduce
Added logging for useAccountEffect.onConnect conditions
wagmi/packages/react/src/hooks/useAccountEffect.ts
Lines 34 to 40 in 34df0c8
https://stackblitz.com/edit/new-wagmi-tfvypz?file=src%2FApp.tsx
open preview in new tab
First time connecting, click Injected: 🟢
Reload page: 🟢
Reload by enabling metamask to run on this site: 🔴
What Wagmi package(s) are you using?
wagmi
Wagmi Package(s) Version(s)
2.12.7
Viem Version
2.0.0
TypeScript Version
5.2.2
Anything else?
No response
The text was updated successfully, but these errors were encountered: