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

Page crashes when injected provider is used. #1447

Closed
MicahZoltu opened this issue May 6, 2021 · 8 comments
Closed

Page crashes when injected provider is used. #1447

MicahZoltu opened this issue May 6, 2021 · 8 comments
Labels
bug Something isn't working

Comments

@MicahZoltu
Copy link
Contributor

Bug Description
Attempting to use an Inejected provider (wallet), the page crashes (white screen with error in console).

Steps to Reproduce

  1. Navigate to https://app.uniswap.org
  2. Click Connect to a Wallet button.
  3. Choose Injected
  4. Notice that the page turns white and you get an error like:
TypeError: Cannot read property 'detectNetwork' of undefined
    at r.value (json-rpc-provider.ts:331)
    at new r (base-provider.ts:487)
    at r.<anonymous> (createSuper.js:12)
    at new r (json-rpc-provider.ts:308)
    at r.<anonymous> (createSuper.js:12)
    at new r (web3-provider.ts:119)
    at ZS (getLibrary.ts:5)
    at provider.tsx:52
    at Object.Eo [as useMemo] (react-dom.production.min.js:168)
    at t.useMemo (react.production.min.js:23)

Expected Behavior
Page doesn't crash.

Additional Context
I suspect that something in the code is making assumptions about what the injected provider provides beyond what is standard. In particular, it seems to want to get network information from the injected provider but is failing.

There are a few issues here:

  1. Uniswap is not gracefully handling the exception and presenting it to the user.
  2. Uniswap is making assumptions about what features the injected provider will have that are beyond the scope of what is standardized across wallets.
  3. Uniswap is not gracefully degrading when a particular feature is missing.
@MicahZoltu MicahZoltu added the bug Something isn't working label May 6, 2021
@tomteman
Copy link

tomteman commented May 6, 2021

Tom from Portis here, please let us know if there is any way we can help.
For example, if there is functionality we can add on our end to better support your flow, we'd be happy to implement it.

@cammellos
Copy link

Hi,
we have the same issue on the status dapp browser.
It looks like it might be an issue with ethers.js
ethers-io/ethers.js#1484

As far as I can see uniswap is serving 5.1.0, and this should be fixed on 5.1.3

@moodysalem
Copy link
Contributor

we have this issue with a number of wallets, it was caused by switching to a newer version of ethers. this workaround should fix it for at least coinbase wallet
d3898cf

@moodysalem
Copy link
Contributor

@cammellos
Copy link

Thanks @moodysalem
Indeed the issue was on that line, just out of curiosity, have you deployed the changes?

I have tried on coinbase wallet & status browser and I get an empty page when accessing app.uniswap.org, but unlike before no error is thrown (though page is completely blank)

The last request made is this one:

request: {"method":"eth_chainId","params":[]}

(I have only looked at the logs on status as I can't access them on the coinbase wallet).

Thanks for the prompt response.

@moodysalem
Copy link
Contributor

moodysalem commented May 6, 2021

@ricmoo we had to workaround a bug in the latest ethers provider package @5.1.1 with this commit
021aab6

the problem is the web3provider constructor super calls json provider constructor super calls base provider constructor which calls detectNetwork before this._eventLoopCache is defined

the result is that json rpc provider does not work if you pass in 'any' network

@moodysalem
Copy link
Contributor

should be fixed in interface

@ricmoo
Copy link

ricmoo commented May 6, 2021

@moodysalem That was fixed in 5.1.3. The current version is 5.1.4.

Updating to the latest version should solve this. Let me know if there are still issues after updating. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants