Hi,
i'm reporting a bug that i'm having after the migration to the new 1.0 version (related to the deprecation of web3). i've updated the dependency and migrated all the function calls to the async ones. in the end i'm continuously getting an error about wrong ids in the response, as you can see in this screenshot.

it seems that the this PR introduced a remapping of ids but i don't know the motivation of implementing such mechanism but now i can't finish the migration because of this error. i'm not used to debugging chrome extensions so i didn't tried to remove that remapping in order to see if the problem would be solved.
is anyone having this issue?
https://github.com/ethereum/web3.js/issues/940 Reported in web3 repo as well
yes, i already saw it. let's wait for @kumavis or someone else!
sounds like a new validation from web3 hitting some metamask bug related to how we rewrite ids for better uniqueness guarantees
at first glance the code looks alright, but likely where the bug as reported lurks
https://github.com/MetaMask/metamask-extension/blob/master/app/scripts/lib/inpage-provider.js#L46-L62
@hrishikeshio @phra need more exact repro instructions -- just call any method with web3 1.0 ?
web3.currentProvider.sendAsync({ id: 1, method: 'eth_getBalance', params: ['0x3AE39E89Dc7e736cCe53091057A45bF44B1A566c'] }, console.log)
VM295:1 MetaMask: web3 will be deprecated in the near future in favor of the ethereumProvider
https://github.com/ethereum/mist/releases/tag/v0.9.0
get @ chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/scripts/inpage.js:85
(anonymous) @ VM295:1
undefined
chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/scripts/inpage.js:174 null {id: 1, result: "0x0"}
web3.currentProvider.sendAsync({ id: 123, method: 'eth_getBalance', params: ['0x3AE39E89Dc7e736cCe53091057A45bF44B1A566c'] }, console.log)
VM298:1 MetaMask: web3 will be deprecated in the near future in favor of the ethereumProvider
https://github.com/ethereum/mist/releases/tag/v0.9.0
get @ chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/scripts/inpage.js:85
(anonymous) @ VM298:1
undefined
chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/scripts/inpage.js:174 null {id: 123, result: "0x0"}id: 123result: "0x0"__proto__: Object
web3.currentProvider.sendAsync([{ id: 123, method: 'eth_getBalance', params: ['0x3AE39E89Dc7e736cCe53091057A45bF44B1A566c'] }], console.log)
VM305:1 MetaMask: web3 will be deprecated in the near future in favor of the ethereumProvider
https://github.com/ethereum/mist/releases/tag/v0.9.0
get @ chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/scripts/inpage.js:85
(anonymous) @ VM305:1
undefined
chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/scripts/inpage.js:174 null [{鈥]0: {id: 123, result: "0x0"}length: 1__proto__: Array(0)
quick check in the console - ids seem to match fine
@hrishikeshio @phra how are you initializing web3?
i'm initializing web3 like this:
import * as Web3 from 'web3'
class Class {
web3Instance: any
constructor() {
this.web3Instance = new Web3(window['web3'].currentProvider)
}
is this wrong? @kumavis
looks correct - will give it ago
Having similar issues call web3.eth.call()
web3.eth.call(
{to: contractAddr, data: callData},
walletAddress,
function (err, data) {
console.log(err);
console.log(data);
}
).then(console.log);

Not sure if anyone already investigated so here are my 3 cents.
https://github.com/MetaMask/metamask-extension/blob/master/app/scripts/lib/inpage-provider.js#L49
var request = eachJsonMessage(payload, (message) => {
var newId = createRandomId()
self.idMap[newId] = message.id
message.id = newId // <-- HERE
return message
})
Above line modifies payload object from:
https://github.com/ethereum/web3.js/blob/1.0.0-beta.18/packages/web3-core-requestmanager/src/index.js#L128
var payload = Jsonrpc.toPayload(data.method, data.params);
this.provider.send(payload, function (err, result) {
if(result && result.id && payload.id !== result.id) return callback(new Error('Wrong response id "'+ result.id +'" (expected: "'+ payload.id +'") in '+ JSON.stringify(payload)));
//...
And when the id of result and payload objects is compared, payload contains randomly generated id but result has properly translated id.
From very brief investigation it looks like solution would be to duplicate payload object so that it's not modified.
var request = eachJsonMessage(payload, (message) => {
var newId = createRandomId()
self.idMap[newId] = message.id
message = Object.assign({}, message); // NEW
message.id = newId
return message
})
For my local testing (modified inpage.js file in devtools) it worked.
@gkapkowski thanks for your findings! hope that @kumavis can have a look soon!
Would be really great if this got looked at. Web3 v1+ is such a better development experience with promises and async functions and its a shame we're not able to upgrade to it to work with metamask.
@gkapkowski thanks for digging - that makes sense - will prioritize
Unfortunately, I am receiving the async error 100% of the time as of this fix.
I am trying to call this.willContract
.new({
from: this.defaultAddress,
})
@JamesKnippel can you confirm your MetaMask version, by going into the top right metamask menu, selecting "Info"?
@flyswatter I've got 3.9.12, current yes?
That is, will have to investigate soon, maybe tomorrow, sorry Web3 1.0 hasn't gotten more priority.
Bummer 馃槩
Web3 1.0 has been an absolute disaster.
I think you could summarize it as "We don't support web3 1.0 yet".
In the meanwhile, I really can't say enough good things about EthJS.
@flyswatter I'll definitely be building my next dapp on EthJS.
Could I manually revert the version to pre 3.9.12 through attaching it to chrome with the restored
inpage-provider.js code?
I have a pretty big presentation due coming up and now my contracts are dead (with most of the front end using web3 1.0) 馃槺
@flyswatter I just refactored my contract function into Ethjs. Don't think it's a 1.0 issue it seems?
this.willByteCode = 'mybytecode'
this.willFactory = this.eth.contract(will['abi'], this.willByteCode, {
from: this.defaultAddress,
gas: 1000000,
});
this.willContract = this.willFactory.new((error, result) => {
if (error) {
console.log(error);
} else {
console.log('did this contract deploy?', result);
this.contractAddress = result.address;
this.contractInstance = result;
}
});
gives the same error in the shiny new _red_ edition
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
Also running into this problem building a react app. Would love to know a fix when there is one 馃憤
Let me know what you need from EthJS, what is causing this, do we think it's on the provider level?
Closing in favor of #2054, which is more specific to this new problem.
@SilentCicero I think we can rule out EthJS, because the same problem was happening with Web3 1.0.
Most helpful comment
Having similar issues call web3.eth.call()