Metamask-extension: Error: sendAsync not overwritten

Created on 8 Sep 2017  路  26Comments  路  Source: MetaMask/metamask-extension

Continuation of #1940, which was really a different bug.
Since the fix to that issue was published, some users are getting an error when trying to interact with the MetaMask Web3, with an error of:

core.es5.js:1020
ERROR Error: Uncaught (in promise): Error: MetamaskInpageProvider - sendAsync not overwritten
Error: MetamaskInpageProvider - sendAsync not overwritten
    at MetamaskInpageProvider.sendAsync (inpage.js:254)
    at EthRPC.sendAsync (index.js:48)
    at index.js:96
    at new ZoneAwarePromise (zone.js:861)
    at Eth.outputMethod [as sendTransaction] (index.js:53)
    at Object.newContract [as new] (index.js:151)
    at DeployContractsComponent.deployWill (deploy-contracts.component.ts:124)
    at Object.eval [as handleEvent] (DeployContractsComponent.html:22)
    at handleEvent (core.es5.js:12014)
    at callWithDebugContext (core.es5.js:13475)
    at Object.debugHandleEvent [as handleEvent] (core.es5.js:13063)
    at dispatchEvent (core.es5.js:8607)
    at core.es5.js:9218
    at HTMLButtonElement.<anonymous> (platform-browser.es5.js:2651)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:425)
    at Object.onInvokeTask (core.es5.js:3881)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:424)
    at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask (zone.js:192)
    at ZoneTask.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:499)
    at invokeTask (zone.js:1427)
    at HTMLButtonElement.globalZoneAwareCallback (zone.js:1445)
    at MetamaskInpageProvider.sendAsync (inpage.js:254)
    at EthRPC.sendAsync (index.js:48)
    at index.js:96
    at new ZoneAwarePromise (zone.js:861)
    at Eth.outputMethod [as sendTransaction] (index.js:53)
    at Object.newContract [as new] (index.js:151)
    at DeployContractsComponent.deployWill (deploy-contracts.component.ts:124)
    at Object.eval [as handleEvent] (DeployContractsComponent.html:22)
    at handleEvent (core.es5.js:12014)
    at callWithDebugContext (core.es5.js:13475)
    at Object.debugHandleEvent [as handleEvent] (core.es5.js:13063)
    at dispatchEvent (core.es5.js:8607)
    at core.es5.js:9218
    at HTMLButtonElement.<anonymous> (platform-browser.es5.js:2651)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:425)
    at Object.onInvokeTask (core.es5.js:3881)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:424)
    at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask (zone.js:192)
    at 

Pinging users who experienced it, @andytudhope and @JamesKnippel. Can you each describe your dev stacks in detail? Are you both using React? Babel? Looking for tools that might be conflicting with MetaMask.

Most helpful comment

checkWeb3 = () => {
    // Checking if Web3 has been injected by the browser, in this case,MetaMask)
    if (typeof typeof window.web3 !== 'undefined') {
      // Use Mist/MetaMask's provider
      console.log('attaching to metamask');
      this.web3 = new Web3(window['web3'].currentProvider);
      this.eth = new Eth(window['web3'].currentProvider);
    } else {
      console.log(
        'No web3 detected. Falling back to infura/http.'
      );
      // fallback
      this.web3 = new Web3(
        new Web3.providers.HttpProvider('https://ropsten.infura.io/') <--- varies *ignore*
      );
    }
  }

this is my instantiation good sir

All 26 comments

@JamesKnippel you asked for ways to install an older version for a presentation in the meanwhile, you can download older releases here:
https://github.com/MetaMask/metamask-extension/releases

You have to add them manually from chrome://extensions Load Unpacked Extension.

@flyswatter Hey, thanks for the interaction!
Currently using Angular 4 with it's built in webpack through the CLI.
I've tried several different routes for contract deployments.
Tried web3 1.0 manual deployment, then tried truffle-contract module, then tried the eth.js as of 3.9.12 and received that send async error.
I cloned the metamask repo and uploaded a modified, pre-3.9.12 update to chrome and started receiving those 'received id of 1' issues from #1940

im on the job 馃攳

@JamesKnippel et al, if you can provide the code for how you're using the web3.currentProvider that would be much appreciated

checkWeb3 = () => {
    // Checking if Web3 has been injected by the browser, in this case,MetaMask)
    if (typeof typeof window.web3 !== 'undefined') {
      // Use Mist/MetaMask's provider
      console.log('attaching to metamask');
      this.web3 = new Web3(window['web3'].currentProvider);
      this.eth = new Eth(window['web3'].currentProvider);
    } else {
      console.log(
        'No web3 detected. Falling back to infura/http.'
      );
      // fallback
      this.web3 = new Web3(
        new Web3.providers.HttpProvider('https://ropsten.infura.io/') <--- varies *ignore*
      );
    }
  }

this is my instantiation good sir

web3.currentProvider.sendAsync // good
web3.currentProvider.constructor.prototype.sendAsync // bad

not sure how you would end up calling the wrong one

If this is any help, I have two separate branches. One that works with Web3 alone, and the other with Ethjs.
1) I wiped both metamask versions I currently have, then started a new chrome instance along with a rebasing to the previous pre-3.9.12 working web3 commit. Upon that action, it WORKED.
2) However, I just switched over to Ethjs once again to try and see if that method resolved (in favor of working with ethjs, per your suggestions) and the error returned.
3) I switched back to web3 branch (that was working per the rebase) and then it broke, async error reappeared.

hmm, @JamesKnippel can you post the errors in full? And describe a little more about what your doing?

@SilentCicero its somehow calling the wrong sendAsync fn

vendor.bundle.js:194751 ERROR Error: Uncaught (in promise): Error: MetamaskInpageProvider - sendAsync not overwritten
Error: MetamaskInpageProvider - sendAsync not overwritten
    at MetamaskInpageProvider.sendAsync (inpage.js:254)
    at EthRPC.sendAsync (index.js:48)
    at index.js:96
    at new ZoneAwarePromise (polyfills.bundle.js:3406)
    at Eth.outputMethod [as sendTransaction] (index.js:53)
    at Object.newContract [as new] (index.js:151)
    at DeployContractsComponent.deployWill (main.bundle.js:190)
    at Object.eval [as handleEvent] (DeployContractsComponent.ngfactory.js:173)
    at handleEvent (core.es5.js:12014)
    at callWithDebugContext (core.es5.js:13475)
    at Object.debugHandleEvent [as handleEvent] (core.es5.js:13063)
    at dispatchEvent (core.es5.js:8607)
    at core.es5.js:9218
    at HTMLButtonElement.<anonymous> (platform-browser.es5.js:2651)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.bundle.js:2970)
    at Object.onInvokeTask (core.es5.js:3881)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.bundle.js:2969)
    at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask (polyfills.bundle.js:2737)
    at ZoneTask.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (polyfills.bundle.js:3044)
    at invokeTask (polyfills.bundle.js:3972)
    at HTMLButtonElement.globalZoneAwareCallback (polyfills.bundle.js:3990)
    at MetamaskInpageProvider.sendAsync (inpage.js:254)
    at EthRPC.sendAsync (index.js:48)
    at index.js:96
    at new ZoneAwarePromise (polyfills.bundle.js:3406)
    at Eth.outputMethod [as sendTransaction] (index.js:53)
    at Object.newContract [as new] (index.js:151)
    at DeployContractsComponent.deployWill (main.bundle.js:190)
    at Object.eval [as handleEvent] (DeployContractsComponent.ngfactory.js:173)
    at handleEvent (core.es5.js:12014)
    at callWithDebugContext (core.es5.js:13475)
    at Object.debugHandleEvent [as handleEvent] (core.es5.js:13063)
    at dispatchEvent (core.es5.js:8607)
    at core.es5.js:9218
    at HTMLButtonElement.<anonymous> (platform-browser.es5.js:2651)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.bundle.js:2970)
    at Object.onInvokeTask (core.es5.js:3881)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.bundle.js:2969)
    at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask (polyfills.bundle.js:2737)
    at ZoneTask.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (polyfills.bundle.js:3044)
    at invokeTask (polyfills.bundle.js:3972)
    at HTMLButtonElement.globalZoneAwareCallback (polyfills.bundle.js:3990)
    at resolvePromise (polyfills.bundle.js:3340)
    at new ZoneAwarePromise (polyfills.bundle.js:3409)
    at Eth.outputMethod [as sendTransaction] (index.js:53)
    at Object.newContract [as new] (index.js:151)
    at DeployContractsComponent.deployWill (main.bundle.js:190)
    at Object.eval [as handleEvent] (DeployContractsComponent.ngfactory.js:173)
    at handleEvent (core.es5.js:12014)
    at callWithDebugContext (core.es5.js:13475)
    at Object.debugHandleEvent [as handleEvent] (core.es5.js:13063)
    at dispatchEvent (core.es5.js:8607)
    at core.es5.js:9218
    at HTMLButtonElement.<anonymous> (platform-browser.es5.js:2651)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.bundle.js:2970)
    at Object.onInvokeTask (core.es5.js:3881)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.bundle.js:2969)
    at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask (polyfills.bundle.js:2737)
    at ZoneTask.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (polyfills.bundle.js:3044)
    at invokeTask (polyfills.bundle.js:3972)
    at HTMLButtonElement.globalZoneAwareCallback (polyfills.bundle.js:3990)

This is the error when I try to deploy using ethjs, I posted my deployment strategy in the last thread I believe.

this is web3's when i change branches back over to my web3 branch coming from ethjs,
mind you, my working strategy used web3 and truffle-contract module but would still provide this error very occasionally

Error: MetamaskInpageProvider - sendAsync not overwritten
    at MetamaskInpageProvider.sendAsync (inpage.js:254)
    at Provider.webpackJsonp.../../../../truffle-contract/contract.js.Provider.sendAsync (contract.js:23)
    at RequestManager.webpackJsonp.../../../../truffle-contract/node_modules/web3/lib/web3/requestmanager.js.RequestManager.sendAsync (requestmanager.js:80)
    at Object.get [as getNetwork] (property.js:116)
    at contract.js:477
    at new ZoneAwarePromise (polyfills.bundle.js:3406)
    at Function.detectNetwork (contract.js:468)
    at Function.new (contract.js:327)
    at DeployContractsComponent.deployWill (main.bundle.js:204)
    at Object.eval [as handleEvent] (DeployContractsComponent.ngfactory.js:173)
    at handleEvent (core.es5.js:12014)
    at callWithDebugContext (core.es5.js:13475)
    at Object.debugHandleEvent [as handleEvent] (core.es5.js:13063)
    at dispatchEvent (core.es5.js:8607)
    at core.es5.js:9218
    at HTMLButtonElement.<anonymous> (platform-browser.es5.js:2651)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.bundle.js:2970)
    at Object.onInvokeTask (core.es5.js:3881)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.bundle.js:2969)
    at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask (polyfills.bundle.js:2737)
    at ZoneTask.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (polyfills.bundle.js:3044)
    at invokeTask (polyfills.bundle.js:3972)
deploy-contracts.component.ts:150 Error: MetamaskInpageProvider - sendAsync not overwritten
    at MetamaskInpageProvider.sendAsync (inpage.js:254)
    at Provider.webpackJsonp.../../../../truffle-contract/contract.js.Provider.sendAsync (contract.js:23)
    at RequestManager.webpackJsonp.../../../../truffle-contract/node_modules/web3/lib/web3/requestmanager.js.RequestManager.sendAsync (requestmanager.js:80)
    at Object.get [as getNetwork] (property.js:116)
    at contract.js:477
    at new ZoneAwarePromise (polyfills.bundle.js:3406)
    at Function.detectNetwork (contract.js:468)
    at Function.new (contract.js:327)
    at DeployContractsComponent.deployWill (main.bundle.js:204)
    at Object.eval [as handleEvent] (DeployContractsComponent.ngfactory.js:173)
    at handleEvent (core.es5.js:12014)
    at callWithDebugContext (core.es5.js:13475)
    at Object.debugHandleEvent [as handleEvent] (core.es5.js:13063)
    at dispatchEvent (core.es5.js:8607)
    at core.es5.js:9218
    at HTMLButtonElement.<anonymous> (platform-browser.es5.js:2651)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.bundle.js:2970)
    at Object.onInvokeTask (core.es5.js:3881)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.bundle.js:2969)
    at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask (polyfills.bundle.js:2737)
    at ZoneTask.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (polyfills.bundle.js:3044)
    at invokeTask (polyfills.bundle.js:3972)

You could just try querying that provider, avoid truffle if possible with https://github.com/ethjs/ethjs-rpc

that is the raw and primitive RPC module that is actually calling sendAsync.

also, you might be interested in an alternative dev stack for developing and deploying contracts:

https://github.com/ethjs/ethjs-contract-boilerplate

;-)

Will try and experiment with that for future projects, but I know it works on my stack because it has before 馃槢

@JamesKnippel we have a branch that might fix this problem for you. Here is a custom build, would you mind trying it with your project?

metamask-chrome-3.9.13.zip

I'll give it a shot!

i audited https://github.com/ethjs/ethjs-rpc and it looks fine, not sure where the issue is coming from
trying to reproduce the issue here

@JamesKnippel noticed a typo typeof typeof window.web3 !== 'undefined'

@JamesKnippel for ethjs are you getting this error for any request or just contract deploy?

@kumavis thanks for that, didn't affect the mounting though.
'bout to test ethjs, getting a new error with the new build related to deployment.
trying to reproduce as many behaviors as possible. I'm on it though!

As of the custom build with 3.1.13. (what'd y'all fix?)
I am no longer receiving sendAsync errors on either Web3 or ethjs branches. Nor when I swap between the two consecutively!
I've reproduced quite a few scenarios where I'd discover bugs and so far I have found none for deployment, I'm going to test some of the other methods I'm calling.
This is awesome y'all!! Thanks so much!

glad that fixes it - wanted to verify, as we're unable to reproduce the issue here

I'm going to keep testing as this project develops, I'm fairly new so I may not know what to look for, but I'm free to share my repo if it will be of potential help!

@JamesKnippel yeah please (and any build instructions)

or if its deployed anywhere non-minified i could use that

Okay, give me a second to finalize some pull requests and make sure you're receiving everything that's up to date

&& the deployed instance is far behind

Does metamask have a slack or a gitter I could message you on for specific details that'll help y'all?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BMillman19 picture BMillman19  路  3Comments

glitch003 picture glitch003  路  3Comments

aecc picture aecc  路  3Comments

MarkOSullivan94 picture MarkOSullivan94  路  3Comments

kumavis picture kumavis  路  3Comments