[Bug]: MetaMask fails to notify or emit disconnect event when wallet is locked
Describe the bug
When you lock the MetaMask wallet, no notification or event is emitted and the internal isUnlocked() flag remains true. In other words, MetaMask “silently” locks without informing the dapp or developer console that the wallet state has changed.
Expected behavior
- MetaMask should emit the standard
"disconnect"event (or a dedicated"lock"event) onwindow.ethereumwhen the wallet is locked. - After locking,
window.ethereum._metamask.isUnlocked()should returnfalse. - The dapp should be immediately aware that the wallet is no longer available for signing or sending transactions.
Screenshots/Recordings
No response
Steps to reproduce
-
Open MetaMask in your browser.
-
Open the developer console on any website.
-
Click your dapp’s “Connect” button to establish a connection with MetaMask.
-
In the console, register a listener for the
"disconnect"event:window.ethereum.on('disconnect', console.log); -
In MetaMask’s extension popup, click Lock.
-
Observe that nothing is logged in the console (no event is emitted).
-
In the console, check the unlocked state:
window.ethereum._metamask.isUnlocked(); // returns true -
Despite having locked the wallet,
isUnlocked()still returnstrueand no"disconnect"event has fired.
Error messages or log output
Detection stage
In production
Version
12.18.3
Build type
None
Browser
Chrome
Operating system
MacOS
Hardware wallet
No response
Additional context
This makes it impossible for dapps to detect when the user has locked their MetaMask wallet, leading to potential UX issues (e.g., attempts to send transactions silently fail or hang).
Severity
No response
Hey @lorof
Thank you for your patience and for reporting this issue. Our team has been focused on shipping several updates, and our latest release contains numerous fixes.
Could you please update to the latest version, 13.4.2, on Chrome and confirm if the issue is still present?
We appreciate your help.
@DanielTech21 Nothing has changed. The disconnect event still doesn't fire.
I am checking this one as part of the Quality Sprint. It's reproducible in 13.12.0.