Web3.js: UnhandledPromiseRejectionWarning: Error: invalid json request [1.0.0-beta.47]

Created on 4 Mar 2019  路  3Comments  路  Source: ChainSafe/web3.js


As was mentioned briefly in this comment, eth.getAccounts() fails with the latest release of web3 and truffle-hdwallet-provider

Expected behavior

Code didn't change, only updated packages, and eth.getAccounts() should return accounts

Actual behavior

Fails.

Steps to reproduce the behavior

const Web3 = require('web3');
const HDWalletProvider = require('truffle-hdwallet-provider');
let provider = new HDWalletProvider(process.env.MNEMONIC, infuraNodeURL(false, network));
let web3 = new Web3(provider);
const accounts = await web3.eth.getAccounts();
// see error below

Error Logs

(node:31402) UnhandledPromiseRejectionWarning: Error: invalid json request
    at /Users/carlos/Desktop/helbiz/hbz-listen/node_modules/truffle-hdwallet-provider/dist/index.js:15:620862
    at e.i.onreadystatechange (/Users/carlos/Desktop/helbiz/hbz-listen/node_modules/truffle-hdwallet-provider/dist/index.js:15:775522)
    at e.t.dispatchEvent (/Users/carlos/Desktop/helbiz/hbz-listen/node_modules/truffle-hdwallet-provider/dist/index.js:1:152983)
    at e._setReadyState (/Users/carlos/Desktop/helbiz/hbz-listen/node_modules/truffle-hdwallet-provider/dist/index.js:15:780284)
    at e._onHttpResponseEnd (/Users/carlos/Desktop/helbiz/hbz-listen/node_modules/truffle-hdwallet-provider/dist/index.js:15:783369)
    at IncomingMessage.<anonymous> (/Users/carlos/Desktop/helbiz/hbz-listen/node_modules/truffle-hdwallet-provider/dist/index.js:15:782627)
    at IncomingMessage.emit (events.js:187:15)
    at IncomingMessage.EventEmitter.emit (domain.js:442:20)
    at endReadableNT (_stream_readable.js:1092:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

Versions

npm: 6.8.0
node: v10.11.0
web3: 1.0.0-beta.47
truffle-hdwallet-provider: 1.0.5

bug

Most helpful comment

@sydneyitguy I will release this fix today.

All 3 comments

I'm having the same issue with this.
Is there any work-around until beta.48 out?

@sydneyitguy I will release this fix today.

Was this page helpful?
0 / 5 - 0 ratings