When a dapp using ethereum.enable() is opened in two browser tabs, reloading two tabs at the same time locks one of them (the other loads successfully).
Steps to reproduce the behavior:
<html>
<body>
<script type="text/javascript">
console.log('init');
ethereum.enable().then(() => console.log('enabled'));
</script>
</body>
</html>
Both tabs should log 'init' and 'enabled' to the console.
Note that I had granted the permission for MetaMask to inject ethereum account for the location, so no popup appeared during the bug reproduction.
To reproduce, the HTML file location must be http://, file:// does not work.
Software versions:
There are more cases of such behavior:
1) In development reloading of page in a background tab, triggered by recompiling source code also locks that page
2) When you reopen chrome browser it restores closed tabs. Metamask enabled page remains locked
+1!
the same issue is on my side guys
I have same issue!
Thanks for filing this @kkostalkowicz. We're investigating this issue now and hope to include a fix as part of the next release.
There is a workaround using an event listener.
Before you need any web3:
document.addEventListener('visibilitychange', this.enable, false)
Enable call:
enable = () => {
if(document.hidden) return;
window.ethereum.enable()
.then((address) => { /* Your setup with enabled web3 */ })
.finally(() => {
document.removeEventListener('visibilitychange', this.enable, false)
});
}