Skip to content
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

ethereum.send never resolve when page is loaded on browser launch (chrome) #7221

Closed
wighawag opened this issue Sep 26, 2019 · 23 comments
Closed
Labels
area-api area-injection Relating to how the JS interface is injected into a website. Sev2-normal Normal severity; minor loss of service or inconvenience. stale issues and PRs marked as stale team-wallet-api-platform type-bug

Comments

@wighawag
Copy link

Describe the bug
After launching chrome, the page/tab that is loaded at launch has window.ethereum present but none of the call to it respond

To Reproduce
Steps to reproduce the behavior:

  1. ensure chrome load a page on launch (it can be the previous page)
  2. ensure chrome is not running
  3. launch chrome
  4. open the console
  5. see the log (see below)
  6. type ethereum.send('net_version') in the console and see the promise never resolve
  7. reload the page
  8. do step 4 to 6 and you ll see the promise resolving

This is what the console shows in step 5:

contentscript.js:1 MetamaskContentscript - lost connection to MetaMask Background Multiplex
s @ contentscript.js:1
contentscript.js:1 MetamaskContentscript - lost connection to MetaMask muxed traffic for channel "provider" failed.
s @ contentscript.js:1
contentscript.js:1 MetamaskContentscript - lost connection to MetaMask muxed traffic for channel "publicConfig" failed.

Expected behavior
I expect all call to ethereum.send to either resolve or fail

Browser details (please complete the following information):

  • OS: Windows 10 (64 bit)
  • Browser: chrome
  • MetaMask Version: 7.2.1
@wighawag
Copy link
Author

Any updates on this ?

To reproduce you just need a webpage that use window.ethereum and that you set your browser to load it on launch. Or alternatively that you set your browser to load the pages "where you left off", and make sure you are on this page when you shutdown the browser.

@gwn
Copy link

gwn commented Jan 31, 2020

I'm experiencing the exact same problem on Chrome 78 on both my Linux and Windows 7 oses. I also managed to reproduce this both on my dapp and several popular dapps using MetaMask. Seems that this is affecting everybody.

@gwn
Copy link

gwn commented Jan 31, 2020

Related: #6817

@gwn
Copy link

gwn commented Feb 1, 2020

I was looking for ways to circumvent this for some time and I found that the only thing I can do is to use the experimental ethereum._metamask.isEnabled method, which thankfully returns false if MetaMask is not working properly. So I can warn the user to refresh the page or something.

The problem is that this method is marked as deprecated and apparently will be removed in Q1 2020.

So I can't do anything else but to ask MetaMask maintainers to keep this method around until this issue is resolved. Or at least communicate us the exact removal date when you have one. Because I'm going to rely on this method in my dapp since it's the only workaround afaik.

@tmashuang
Copy link
Contributor

tmashuang commented Feb 13, 2020

I would like some clarification on

  1. ensure chrome load a page on launch (it can be the previous page)
  2. ensure chrome is not running
  3. launch chrome

Would my Chrome setting On Startup need to be on Continue where you left off? It seems that the issue you are describing requires Chrome to be closed and reopened to the tab that is reopened on startup.

If this is the case, that would mean either we are not reinitializing the background when Chrome is disconnecting them on browser close. This would require a look if Chrome allows us to reconnect and reload the background processes. I would assume this is achievable since uBlock works the correct way in these situations but their implementation could be different.

I am guessing that when the browser is reopened and the tab is manually refreshed the connection is reestablished again in this situation.

@wighawag
Copy link
Author

Yes that's correct if you use " Continue where you left off" and you were browsing the application using metamask, then this issue will appear. It could also appear if the application is set as the home page.

@xrow
Copy link

xrow commented Apr 21, 2020

I see the same issue.

@wighawag
Copy link
Author

Hey @bdresser any attempt to reproduce it on your side?
This is a pretty serious issue : metamask is not usable on website that get first loaded when you start chrome
Plus it is very easy to reproduce.

@wighawag
Copy link
Author

@danfinlay Any way this could be look at ?

@wighawag
Copy link
Author

This issue is still present in version 8.0.4

@tmashuang tmashuang added area-injection Relating to how the JS interface is injected into a website. area-background Issues relating to the extension background process. P2-sooner type-bug and removed needs-reproduction area-background Issues relating to the extension background process. labels Nov 13, 2020
@Gudahtt Gudahtt added Sev2-normal Normal severity; minor loss of service or inconvenience. and removed P2-sooner labels Jan 7, 2021
@Gudahtt
Copy link
Member

Gudahtt commented Jan 19, 2021

Related to #5936

@blabno
Copy link

blabno commented Jan 14, 2022

According to https://docs.metamask.io/guide/getting-started.html#connecting-to-metamask

You should never initiate a connection request on page load. You should only initiate a connection request in response to direct user action, such as clicking a button.

@wighawag
Copy link
Author

@blabno the issue happen when you do a request at any point, as described in the reproduction step above

@FatTigerWang
Copy link

This problem still exists in Metamask 10.12.1, I was able to reproduce it in Chrome and Firefox.

@Dope-Ass-Ninja
Copy link

Problem still exists. Chrome (Brave) and Firefox, multiple machines. MM v 10.15.1

@Dope-Ass-Ninja
Copy link

Dope-Ass-Ninja commented Aug 11, 2022

as @blabno mentioned, you should never initiate a request on page load. This is a correct statement but is not related to the issue many developers have been facing with the MetaMask extension.

Reproduction Example
Save this link somewhere you can access outside of a browser (like discord or even a shortcut):
https://docs.metamask.io/guide/getting-started.html#connecting-to-metamask

Open that link, thus opening a new browser session (no tabs / pages open), and try using MetaMask's button for initiating a connection.

You will get a message that the connection was successful from the website, but you should not receive a MetaMask pop-up or wallet connection. You will also be able to find the below errors in the dev tools console upon direct page load:

MetaMask: Content script lost connection to "MetaMask Background Multiplex". undefined
contentscript.js:1 MetaMask: Muxed traffic for channel "metamask-provider" failed. undefined
contentscript.js:1 MetaMask: Content script lost connection to "MetaMask Background Legacy Multiplex". undefined
contentscript.js:1 MetaMask: Muxed traffic between channels "provider" and "metamask-provider" failed. undefined
contentscript.js:1 MetaMask: Muxed traffic for channel "publicConfig" failed. undefined

Please provide some comment on this issue as I've been finding references to this dating back to 2019.

@wighawag
Copy link
Author

Any updates on this ?

This is a severe issue that is not addressed since 2019.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 4, 2023

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. The 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. Thank you for your contributions.

@github-actions github-actions bot added the stale issues and PRs marked as stale label Sep 4, 2023
@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 19, 2023
@Mattijah
Copy link

Still experiencing the same issue. The request either doesn't resolve or it takes like 3 minutes for it to return anything back. There is something going on with the connection. Can't believe this has been just closed

@jiexi
Copy link
Contributor

jiexi commented Dec 5, 2023

Hello all. Thanks for reporting this. Could you help us verify something by disabling preloading in your Chrome settings? This can achieved by:

Opening chrome settings
Searching for "Preload"
Toggling the "Preload pages" setting to off
After you do this, are you still able to reproduce the bug you are seeing?

I suspect this is a Chrome specific issue with contentscript to background script connections being dropped on prerendered pages. Thanks!

@jiexi jiexi reopened this Dec 5, 2023
@github-actions github-actions bot removed the stale issues and PRs marked as stale label Dec 5, 2023
Copy link
Contributor

github-actions bot commented Mar 4, 2024

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. The 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. Thank you for your contributions.

@github-actions github-actions bot added the stale issues and PRs marked as stale label Mar 4, 2024
Copy link
Contributor

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.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-api area-injection Relating to how the JS interface is injected into a website. Sev2-normal Normal severity; minor loss of service or inconvenience. stale issues and PRs marked as stale team-wallet-api-platform type-bug
Projects
Archived in project
Development

No branches or pull requests

15 participants