• Ubuntu 18.04 LTS
  • Node.JS: 8.3.0
  • WebJS:
  • web3: ^1.0.0-beta.37
  • web3-utils: ^1.0.0-beta.36
  • npm: 5.6.0
  • Truffle version 5.x (latest)

I have traced through the HttpProvider code in the Web3 package and what I see is quite strange. The provider's onreadystatechange gets a DONE/4 event even though Ganache does not receive a request.

To test this, I initiate a sendSignedTransaction() call from my Node.JS app with a breakpoint set right on the actual low-level send() method the provider uses to contact Ganache with the actual RPC request. When the breakpoint is hit, I shut down Metamask to stop any other entity from making requests to Ganache. I switch to another instance of my development IDE that has the ganache-cli repo loaded. This repo has ganache-core resident as one of its packages. I set breakpoints on the Ganache core server's on-data and on-end event handlers for the request object to make sure I trap any RPC request activity during the test.

With everything in place for a clean test, I resume execution of my Node.JS app and discover that the Web3JS code for the HttpProvider that made the request already processing a result and as you can see in the screenshot below, the result variable is an empty string:

screenshot from 2018-12-19 00-18-59

This results in that code throwing an InvalidResponse error. I have run this test several times and I always see the exact same behavior. That is, the exact same sequence of code paths taken. What could cause the Web3 provider's XMLHttpRequest to believe it already has received a response from Ganache when at least from Ganache's point of view, WebJS never even sent the request?

The last time I saw anomalies like this one was when I learned the hard way that you have to BigNumber everything related to gas values. Assuming I haven't done something wrong and that's always strong possibility, it really feels like some other code in Web3JS is causing the event emitter code to misfire or suffer perhaps some data structure corruption. I say this because except for the one particular smart contract method that results in this error when I call it, all the other method calls work perfectly and there's quite a few of those. I believe there's something about the arguments I am passing with this specific smart contract method and the way Web3JS is trying to parse the arguments against, or match them up to the Solidity ABI is resulting in an unexpected error.

Any tips you can give for debugging this would be appreciated. Otherwise I have a long debug hunt in front of me.

Solidity method being called:

function finalizeGame( address payable _paymentAndEscrowWarehouseAddr, uint256 _clientReferenceTimestamp, uint256 _gameId )

Node.JS code calling that method: return ebbDetails.contractInstanceObj.methods.finalizeGame( paymentsAndEscrowContractAddr, dataBag.paymentStartTimestamp, dataBag.idInSmartContract);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.