question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[bug] Disconnect not persisting and reconnecting on page load

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Package Version

0.0.17

Current Behavior

Using a Next.js app, Im calling the disconnect function from the useAccount hook. It does disconnect but then after refreshing the page it reconnects again and the account info re-populates

Expected Behavior

I would expect to be disconnected from ym wallet so that I may be able to reconnect again with a different wallet or simply use the site in its disconnected state

Steps To Reproduce

  1. Connect via InjectedConnector -> useAccount becomes populated with data and useConnect returns connected:true.
  2. Press disconnect button which calls the disconnect function. -> useAccount returns empty data as expected and connected: false.
  3. Refresh the page
  4. usAccount becomes populated with data again and connected:true

Anything else?

No response

Edit: It seems as though if I remove autoConnect prop on the provider then it does indeed keep me disconnected however that then means on every refresh I need to reconnect. Ideally I would like connect automatically until I explicitly call disconnect

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sammdeccommented, Jan 6, 2022

Ah ok yeah that makes sense! Happy to stick what the most default behaviour is in that case

0reactions
tmmcommented, Jan 6, 2022

@sammdec MM (and other injected providers) don’t support programmatically disconnecting.

I agree it’s confusing to reconnect on page reload, but technically it’s the most accurate since the account is still connected to the browser. (wagmi does handle disconnect events coming from connector directly. For example, disconnecting in MM UI.)

That said, you could manage connection status separately in the browser, but you would need to listen and handle different connection events (i.e. disconnecting or switching account directly through MM extensions).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Must disconnect then reconnect WiFi to load pages.
It always says I am connected but acts as if it isn't, then as I described I go through the procedure and the...
Read more >
socket.io not reconnecting after a disconnect
Said another way, properly configured socket.io code should not have to include the code in your answer. Make a connection once and let...
Read more >
Client socket.disconnect does not stop reconnection attempts
When you call connect() again the reconnection is not working anymore. The main problems are that in the method "Manager.prototype.reconnect" a variable "this....
Read more >
Most common website connection issues and how to ...
1. Authentication Failed ... When it comes to this issue, the first thing that should come to your mind is cache! This usually...
Read more >
After disconnecting client, reconnecting is not working.
So, when I disconnect and go back to the main menu, when the player presses the button "Play", I delete everything and load...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found