metamask-extension icon indicating copy to clipboard operation
metamask-extension copied to clipboard

[Bug]: MetaMask fails to notify or emit disconnect event when wallet is locked

Open lorof opened this issue 6 months ago • 3 comments

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) on window.ethereum when the wallet is locked.
  • After locking, window.ethereum._metamask.isUnlocked() should return false.
  • 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

  1. Open MetaMask in your browser.

  2. Open the developer console on any website.

  3. Click your dapp’s “Connect” button to establish a connection with MetaMask.

  4. In the console, register a listener for the "disconnect" event:

    window.ethereum.on('disconnect', console.log);
    
  5. In MetaMask’s extension popup, click Lock.

  6. Observe that nothing is logged in the console (no event is emitted).

  7. In the console, check the unlocked state:

    window.ethereum._metamask.isUnlocked(); // returns true
    
  8. Despite having locked the wallet, isUnlocked() still returns true and 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

lorof avatar Jun 16 '25 18:06 lorof

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 avatar Oct 10 '25 14:10 DanielTech21

@DanielTech21 Nothing has changed. The disconnect event still doesn't fire.

lorof avatar Oct 13 '25 08:10 lorof

I am checking this one as part of the Quality Sprint. It's reproducible in 13.12.0.

epop-cs avatar Dec 09 '25 19:12 epop-cs