Web3.js: Invalid JSON RPC response error after release 1.2.10

Created on 18 Jul 2020  路  5Comments  路  Source: ChainSafe/web3.js

I have the following error with the release 1.2.10, an error that does not happen in my case with the 1.2.9.

It happens with the call to web3.eth.getCoinbase

Expected behavior

Print the user address

Actual behavior

Print the error

Code to reproduce the behavior

App = {    
    web3Provider: null, // Web3 provider
    url: 'http://localhost:9545', // Url for web3
    account: '0x0', // current ehtereum account
    init: function() { 
        return App.initWeb3(); 
    },

    initWeb3: function() { 
        if(typeof web3 != 'undefined') { 
            App.web3Provider = window.ethereum;
            web3 = new Web3(App.web3Provider);
            try { 
                ethereum.enable().then(async() => { console.log("DApp connected"); });
            }
            catch(error) { console.log(error); }
        }else { 
            App.web3Provider = new Web3.providers.HttpProvider(App.url); 
            web3 = new Web3(App.web3Provider);
        }
        return App.initContract();
    },

    initContract: function() {
        //Here the error happens
        web3.eth.getCoinbase(async function(err, account) {
            if(err == null) {
                App.account = account
                console.log(App.account)
            }else{
                console.log(err) //Here the error print
            }
        });
    }
}
App.init()

Logs

Error: Invalid JSON RPC response: "0xf23a36f9de265fa19c60c9d59488b893474a1571"
at Object.InvalidResponse (unpkg.com/web3@latest/dist/webpack:/packages/web3-core-helpers/src/errors.js:45)
at apply (unpkg.com/web3@latest/dist/webpack:/packages/web3-core-requestmanager/src/index.js:176)
at apply (unpkg.com/web3@latest/dist/webpack:/node_modules/node-libs-browser/node_modules/util/util.js:689)
at b.run (unpkg.com/web3@latest/dist/webpack:/node_modules/process/browser.js:153)
at p (unpkg.com/web3@latest/dist/webpack:/node_modules/process/browser.js:123)

Environment

  • web3.js 1.2.10
  • Tested on Chrome and Firefox with Metamask

All 5 comments

I have the same issue

window.web3` = new Web3(window.ethereum); window.web3.eth.getAccounts() .then(console.log) .catch(console.log)

Logs
Error: Invalid JSON RPC response: ["0xTheActualAddressHere"]
at Object.InvalidResponse (errors.js:45)
at onResult (index.js:176)
at cb (util.js:689)
at Item.push../node_modules/process/browser.js.Item.run (browser.js:153)
at drainQueue (browser.js:123)

Environment:
web3.js 1.2.10
tested on Chrome

hey @ferru97 @jfdelgad thanks for reporting and really sorry about this, I mistakenly though the new Provider.request returns a jsonrpc response object but in fact it returns just the inner result. I opened #3647 to fix and will prepare to push out a v1.2.11 release shortly with the fix.

hey @ferru97 @jfdelgad, v1.2.11 is released now if you could give it another try and let me know if it works for you! thanks again.

hi @ryanio thanks for the fast fix, now it works perfectly!

Thanks for the quick response, all is good now!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FradSer picture FradSer  路  3Comments

ragnu picture ragnu  路  3Comments

zamoore picture zamoore  路  3Comments

praveengupta0895 picture praveengupta0895  路  3Comments

SCBuergel picture SCBuergel  路  3Comments