MetaMask / MetaMask/metamask-extension
Need to reconnect when changing Ganache workspaces
- Dominant language
- TypeScript
- Stars
- 13.2k
- Forks
- 5.6k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 451
Description
**Describe the bug**
When doing some tests on a dapp recently, I noticed MetaMask performing super slow due to [Issue #6813](https://github.com/MetaMask/metamask-extension/issues/6813). As a workaround, I got rid of the existing workspace in Ganache and replaced it with a new workspace, redeploying to the new workspace successfully.
However, in my dapp, I kept getting the error `Cannot read property '0' of null` when trying to do a `.call()` to read a value from a blockchain function. I could not figure out where this was coming from.
Eventually, I found that switching MetaMask's networks selector away from the Ganache network (e.g. to mainnet) and back solved the issue. I'm posting this here because it is a bug that wasted a nontrivial amount of time. Ideally that bug will be fixed, but at least until then someone else encountering the issue might be able to find this page and the workaround above.
**To Reproduce**
I have not tested minimal reproduction steps, but I'm guessing something like this:
1. Interact with a dapp running on local Ganache.
2. Discard that workspace and create a new one.
3. Redeploy the app to the new workspace.
4. Refresh the page in the browser window, and attempt to interact with the dapp.
5. Open the console to observe the errors, and notice the dapp not functioning correctly.
**Expected behavior**
MetaMask reconnects to the new Ganache workspace seamlessly, on page refresh.
**Versions:**
- OS: Win10
- Hardware Wallet: None
- Browser: Google Chrome | 81.0.4044.138 (Official Build) (64-bit) (cohort: Stable)
- MetaMask Version: 7.7.9
- Ganache Version: 2.1.2
Contributor guide
Research direction
Start by reproducing the issue with a dapp connected to a local Ganache workspace: replace the workspace, redeploy, refresh the page, and inspect the console during a contract .call(). Done means MetaMask reconnects to the new workspace on page refresh without the reported null-property error; switching networks away and back is the documented workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- blockchain
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100