Web3.js: Cannot read property of blockNumber of null

Created on 28 Jan 2019  路  9Comments  路  Source: ChainSafe/web3.js

sendSignedTransaction call back 'confirmation' is called when transaction is mined on ropsten/mainnet

Callback is not called. Error is thrown

Steps to reproduce the behavior

Package.json:

```
"dependencies": {
"@babel/runtime": "^7.3.1",
"async": "^2.6.1",
"bignumber.js": "^8.0.2",
"ethereumjs-tx": "^1.3.7",
"loadash": "^1.0.0",
"lodash": "^4.17.11",
"math": "^0.0.3",
"mathjs": "^5.4.1",
"moment": "^2.24.0",
"mysql": "^2.16.0",
"request": "^2.88.0",
"solc": "^0.4.24",
"uuid": "^3.3.2",
"web3": "^1.0.0-beta.37"
},


call :  web3.eth.sendSignedTransaction('0x' + serializedTx)

#### Error Logs

following error is thrown:

(node:62482) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'blockNumber' of null
at Object.outputTransactionFormatter (/Users/karanahuja/airflow/dags/node_modules/web3-core-helpers/dist/web3-core-helpers.cjs.js:91:15)
at GetTransactionReceiptMethod.afterExecution (/Users/karanahuja/airflow/dags/node_modules/web3-core-method/dist/web3-core-method.cjs.js:497:30)
at GetTransactionReceiptMethod._callee$ (/Users/karanahuja/airflow/dags/node_modules/web3-core-method/dist/web3-core-method.cjs.js:455:39)
at tryCatch (/Users/karanahuja/airflow/dags/node_modules/regenerator-runtime/runtime.js:62:40)
at Generator.invoke [as _invoke] (/Users/karanahuja/airflow/dags/node_modules/regenerator-runtime/runtime.js:288:22)
at Generator.prototype.(anonymous function) [as next] (/Users/karanahuja/airflow/dags/node_modules/regenerator-runtime/runtime.js:114:21)
at asyncGeneratorStep (/Users/karanahuja/airflow/dags/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (/Users/karanahuja/airflow/dags/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
at mous>
at process._tickCallback (internal/process/next_tick.js:189:7)
(node:62482) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:62482) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
```

Versions

[NPM, Node, Web3.js, OS, device...]

Node: v8.12.0
Npm: 6.4.1
web3: "^1.0.0-beta.37"
"@babel/runtime": "^7.3.1",
"solc": "^0.4.24",

bug

Most helpful comment

@0x-genesys Nope anything is fine :-)
I had to update the afterExecution method of the GetTransactionReceiptMethod class. I didn't handle the case if the method is returning null.

All 9 comments

My .on('Confirmation', {} => ) callback is not called after the above error is thrown. Looks like an error in web3core when sendSignedTransaction is called.

@0x-genesys Thanks for submitting this issue!

Which provider are you using?

Thanks for your prompt response @nivida . I am using HttpProvider , with an infura url:

web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/v3/XXX"));

Oh so issue was in 'receipt' , not 'confirmed'. Once the PR is merged, do I need to re-install node_modules?

@0x-genesys Nope anything is fine :-)
I had to update the afterExecution method of the GetTransactionReceiptMethod class. I didn't handle the case if the method is returning null.

when can the response from the RPC be null?

As described here, will the eth_getTransactionReceipt JSON-RPC method return the value null when no receipt was found.

Im still facing the error. Tried running:

rm -rf node_modules && npm i

@nivida am I missing something?

@nivida I'm not sure if it is helpful, but I am experiencing a similar behavior, is it possible that one of the other calls to outputTransactionFormatter is being passed null?

Was this page helpful?
0 / 5 - 0 ratings