Describe the bug
After downloading builds 5b5d390 and d496e2d from PR #4703 and testing them against a sample dApp implementation using window.ethereum.enable(), I was unable to successfully access user accounts after approving access, due to an error in the enable call. Denying access worked as expected.
A minimal example of my code looks like:
if (window.ethereum) {
try {
await ethereum.enable()
console.log(window.ethereum)
} catch (error) {
console.error(error)
}
}
The full stack trace of the error is attached.
To Reproduce
5b5d390 and d496e2dScreenshots

Expected behavior
For window.ethereum.enable() to function correctly and grant my dApp access to user accounts.
Browser details (please complete the following information):
Chrome: Version 69.0.3497.100 (Official Build) (64-bit)
OS: macOS High Sierra 10.13.6 (17G65)
MetaMask: 4.9.3 (5b5d390 and d496e2d)
UI: New/Beta
Additional context
I also tested out the Firefox builds, with the same result. I thought that the problem might stem from me using http and localhost, so I briefly spun up an https localhost, but still had the same result.
Hi @NoahHydro, thanks for your detailed bug report. After trying the steps listed, we're unable to reproduce the error you described. For reference, here's exactly what we did:
d496e2d for Chrome.html
<html>
<head>
<script>
window.addEventListener('load', async () => {
if (window.ethereum) {
try {
await ethereum.enable()
console.log(window.ethereum)
} catch (error) {
console.error(error)
}
}
})
</script>
</head>
</html>

Despite not being able to reproduce the issue, the message associated with the error you described is indicative of a failed provider.send({ method: 'eth_accounts' }) call here. To be safe, we updated the logic around this operation.
Could you please try the latest build from 3d47dbd and let us know if you still experience this issue? If you do, would it be possible to provide the relevant initialization code from your dapp? Thanks in advance.
Hi @bitpshr, thanks for the super fast turnaround! I can confirm that build 3d47dbd fixes my issue locally! (@NoahHydro is my other account, sorry for the double identity.)
I'm not sure why the error is not reproducible via your script, it must be something unique to my project. One thought was that I mistakenly tried to initialize a const web3js = new Web3(window.ethereum) instance against [email protected], but I just tested it locally without that line, which didn't fix the issue I was having with the older builds.
Let me know if you'd like me to do some more digging to try to figure out what part of my local project was causing the failure. Possibly something related to me using the new UI?
Regardless, thanks for pushing this fix!
Glad to hear things are resolved @NoahZinsmeister. Please let us know if you encounter any other issues while testing against the 1102 PR.
Will do, thanks!