-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Bug]: Chromium browser extension is not injecting/initializing window.ethereum on clean start, related to security permissions? #14283
Comments
Looks like it depends on how fast you open the dapp website after browser start.. if you wait after the start of the browser and then open the site then it works but if you open dapp site right away, it is not working until a window refresh.. People who open a dapp site from a link in Discord for example, without prior having the browser loaded, will be greeted with a broken dapp until they refresh that browser tab - and no notification about the plugin being the culprit here. Will seem like the website itself is broken |
I can confirm this. It happens to me too. If I start chromium and open a metamask-enabled dapp right away it will stop working until I refresh the page. |
Using svelte-web3 this is how you can fix it for now: // Use this function on:click of connect button
async function connectMetmask() {
if (window.ethereum) {
// Check that MetaMask is present & not glitched
if (!window.ethereum._state.isConnected && browser) {
// Page was opened too fast after start-up, MetaMask is glitched, setting marker & then reloading..
sessionStorage.setItem('shouldTriggerMetamask', JSON.stringify(true));
// Marker set so let's refresh page and then key in sessionStorage will be read as soon as defaultEvmStores
// is ready and then reactive function below will re-trigger MetaMask sign-in
// We have to wait a little bit here (1000 ms seems enough from initial testing) for MetaMask to
// initialize and inject itself into the chromium.. otherwise it will still be glitched after the
// forced reload as all of this (the reload and re-trigger) happens really fast
// I would recommend to show modal with a loader here telling them to:
// 'Please wait while MetaMask is initializing..'
setTimeout(() => {
window.location.reload();
}, 1000);
return;
}
// If all is good & MetaMask not glitched, we can trigger MetaMask popup to sign-in
defaultEvmStores.setBrowserProvider();
// I would show modal with a loader here tellin them to:
// 'Please authorize the MetaMask sign in to continue..'
} else {
// I would advise to show modal with an error saying:
// 'No wallet plugin detected'
}
}
// Reactive function that will run when defaultEvmStores is ready
$: if (defaultEvmStores && browser) {
// Read the sessionStorage value to check if we should trigger MetaMask popup for sign-in
const shouldTriggerMetamask = JSON.parse(sessionStorage.getItem('shouldTriggerMetamask'));
if (shouldTriggerMetamask) {
// Set the sessionStorage key to false so next reload doesn't trigger again
sessionStorage.setItem('shouldTriggerMetamask', JSON.stringify(false));
// Trigger MetaMask popup to sign-in
defaultEvmStores.setBrowserProvider();
// I would show modal with a loader here tellin them to:
// 'Please authorize the MetaMask sign in to continue..'
}
}
|
I'm also seeing this. Although, this is happening to me also. If I'm not already logged into my account I need to refresh my browser. Although, this doesn't happen all the time. Seems to be more intermittent. |
It happens 100% of the time if you don't have browser opened and click a link from Discord.. so it depends on the time passed since browser was started - seems metamask will not be ready if dApp starts as soon as browser starts and it will bug out until you refresh.. |
Same issue with a lot of users complaining about this, has there been an update? |
Happy new year, any fix for this yet? |
This issue has been automatically marked as stale because it has not had recent activity in the last 90 days. It will be closed in 45 days if there is no further activity.\n\nThe MetaMask team intends on reviewing this issue before close, and removing the stale label if it is still a bug. We welcome new comments on this issue. We do not intend on closing issues if they report bugs that are still reproducible.\n\nThank you for your contributions. |
This issue was closed because there has been no follow up activity in the last 45 days. If you feel this was closed in error, please reopen and provide evidence on the latest release of the extension. Thank you for your contributions. |
Describe the bug
Are you aware that on Chromium browsers when a clean start is performed and a dapp site opened straight away, the MetaMask addon does not work at all and requires a refresh to that tab to finally be registered by any Web3 site. Basically you can test/reproduce this yourself on for example the Doodles homepage: https://doodles.app/ Make sure you do a complete fresh start of a Chromium browser and open that url right away (this is important, you have to open dapp as quickly as possible after browser startup). When you then try to go and click on the Connect > MetaMask, absolutely nothing happens. If you then still sign into MetaMask, site still doesn't register it. You have to refresh the page to get it to show up on the web3 site.
Steps to reproduce
Error messages or log output
No response
Version
10.11.3
Build type
No response
Browser
Chrome, Microsoft Edge
Operating system
Windows
Hardware wallet
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: