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

MetaMask - RPC Error: The method undefined does not exist/is not available #7710

Closed
JaceHensley opened this issue Dec 16, 2019 · 8 comments
Closed
Labels
area-permissions Issues relating to exposing permissions from the trusted MetaMask context to less-trusted contexts.

Comments

@JaceHensley
Copy link

Describe the bug
When calling window.ethereum.send('eth_requestAccounts') it throws MetaMask - RPC Error: The method undefined does not exist/is not available. I can only reproduce this on localhost.

To Reproduce
I can only reproduce this locally at this time

Expected behavior
I would expect this not to throw that error message

Browser details (please complete the following information):

  • OS: OS X
  • Browser: Firefox
  • MetaMask Version: 7.7.1
@JaceHensley
Copy link
Author

If I change it to .send({method: 'eth_requestAccounts', params: []}) the issue goes away

@Ramarti
Copy link

Ramarti commented Dec 18, 2019

Same:
OS: OS X
Browser: Chrome
MetaMask Version: 7.7.1

but changing it to
.send({method: 'eth_requestAccounts', params: []})

Just gave me:

actions.js:60 Uncaught (in promise) TypeError: Cannot read property 'then' of undefined
    at actions.js:60
    at new Promise (<anonymous>)
    at _callee2$ (actions.js:52)
    at tryCatch (runtime.js:62)
    at Generator.invoke [as _invoke] (runtime.js:296)
    at Generator.prototype.<computed> [as next] (runtime.js:114)
    at asyncGeneratorStep (asyncToGenerator.js:5)
    at _next (asyncToGenerator.js:27)
.......
Show 107 more frames
2inpage.js:1 Uncaught TypeError: e is not a function
    at inpage.js:1
    at inpage.js:1
    at i (inpage.js:1)
    at inpage.js:1
    at inpage.js:1
    at c (inpage.js:1)
    at inpage.js:1
    at We (inpage.js:1)
    at Object.<anonymous> (inpage.js:1)
    at e.exports._runReturnHandlersUp (inpage.js:1)

Had the same following the Medium post

@eccentricexit
Copy link

eccentricexit commented Dec 21, 2019

Same issue as Ramarti. I find it quite scary that the suggested method is not working and the breaking update is coming Q1 2020.

@katastrofix
Copy link

katastrofix commented Dec 23, 2019

I encounter the same error.
I bring web3 version 1.2.1 and initialize it with the MetaMask provider.
window.localWeb3 = new Web3( window.ethereum)

If I don't override the web3 version that is injected by Metamask this error does not occur and the

localWeb3.currentProvider.send('eth_requestAccounts').then( ()=>{...})

works properly.

I order to avoid this issue I fallback to
localWeb3.currentProvider.enable()
for establishing wallet connection and i use the
localWeb3.eth.getAccounts()
in order to retrieve the accounts.

On its own the
localWeb3.eth.getAccounts()
doesn't show the MetaMask popup promt for establishing wallet connection, that is why is use enable(). However this method is documented as "to be deprecated"and so I too am confused on how to implement dependent connection to MetaMask in my app and be ready for future releases.

OS: Windows 10
Browser: Chrome
MetaMask Version: 7.7.1

@danfinlay
Copy link
Contributor

danfinlay commented Dec 23, 2019

Hi all, I'm here to clarify the current situation:

TLDR:

  • The syntax ethereum.send(methodName) is not available yet, and won't be until early 2020.
  • We will only break any APIs after the new methods have been available for at least 6 weeks.
  • Apologies for even communicating the coming change before you could do anything about it.
  • The sendAsync() method is not going to change or break, so using it is one safe way to avoid these issues.
  • You can call ethereum.enable() as a promise-returning alternative to eth_requestAccounts today.

First of all, I'm very sorry for the confusion. "Breaking changes" are some of the worst things we ever have to subject developers to, and rolling them out is always a delicate thing, and we had some communication issues with this one, where we announced the changes before developers actually had a migration path to build on.

The new syntax send(methodName, params) which will return a promise, is not yet available in production. This is a part of the EIP 1193 specification that we do not yet support, so for now your best path is to continue using the good old workhorse ethereum.sendAsync(options, callback), which is not going to be broken by any of the coming changes. The changes are exclusively breaking a few old synchronous methods, and also adding a new syntax for returning promises from a pure send() call.

We started rolling out the breaking change in November, but we found some usability issues with some of the changes, which we decided to roll back and fix before publishing it again.

You can read more about the state of the related branch here.

Sorry again for the confusion, for now the proper way to call requestAccounts is:
ethereum.sendAsync({ method: 'requestAccounts' }, function (err, result) { /** Handle result **/ });

You can also call ethereum.enable() for the same result, which does return a promise, even today.

@jennypollack jennypollack added area-permissions Issues relating to exposing permissions from the trusted MetaMask context to less-trusted contexts. T06-devQuestion labels Jan 8, 2020
@Gudahtt
Copy link
Member

Gudahtt commented Jan 8, 2021

Thanks for the question! I'll close this now, as it seems to have been adequately answered. Please see our documentation for further information: https://docs.metamask.io/guide/

@Gudahtt Gudahtt closed this as completed Jan 8, 2021
@ashish-mehta
Copy link

ashish-mehta commented Feb 11, 2021

  1. Goto https://docs.metamask.io/guide/getting-started.html#connecting-to-metamask
  2. Make sure you are logged out from metamask
  3. Enable ethereum
  4. Close the metamask window without logging in
  5. Open console in developer tools f12
  6. Click the enable ethereum again
  7. One can see the errors: MetaMask - RPC Error: Request of type 'wallet_requestPermissions' already pending for origin https://docs.metamask.io.

What to do in this situation?

@taaha827
Copy link

taaha827 commented Mar 4, 2021

I am also facing the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-permissions Issues relating to exposing permissions from the trusted MetaMask context to less-trusted contexts.
Projects
None yet
Development

No branches or pull requests

9 participants