Web3.js: Warning: a promise was created in a handler but was not returned from it

Created on 31 Jul 2017  Â·  7Comments  Â·  Source: ChainSafe/web3.js

I am using the current web3 (version 1.0.0-beta.13) library and have been getting this error continuously, after debugging through the web3 library it seem to return a promise object, which should work with my current implementation.

Here is the error that I am getting:

(node:24273) Warning: a promise was created in a handler but was not returned from it

```js
{ blockHash: '0xd6613704cf1b2aa5e74082eb5ff2f3d3bd93741e97bc2126c7cc295be7207192',
blockNumber: 239,
contractAddress: null,
cumulativeGasUsed: 25290,
gasUsed: 25290,
logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
root: null,
transactionHash: '0x3679g30f86b763400a43bcdbb8bc3db113d3f40dcb47793ff00b8e7ce1dda20fb',
transactionIndex: 0,
events: {} }


I am currently calling the function with the current web3 api:
```js
MyContract.methods.create(‘name’).send({ from: ‘0x4516b04549bd109a3106764dcb473e51fd0cf835’ })
.then(result => console.log(result))
bug

All 7 comments

Should be fixed in the next release beta.14

The same issue with contract deploying in [email protected]. The web3 code to reproduce:

        var contractInstance = new web3.eth.Contract(abi);
        var deployOpts = {
          data: "0x" + bin,
          arguments: params
        };

        var sendOpts = {
          from: accounts[0],
          gas: estimatedGas,
          gasPrice: 21000000000
        };

        contractInstance.deploy(deployOpts).send(sendOpts)
        .then(function(newContractInstance){
          console.log(newContractInstance);
          cb(null, newContractInstance.options.address);
        });

Could this issue be reopened? Or should I create a new one?

@vbaranov Try upgrading to beta.25. I was having the same issue on beta.18 but upgrading fixed it for me. FWIW the function throwing the warning for me was:

const sendSigned = (tx) => {
  return new Promise((resolve, reject) => {
    web3.eth.sendSignedTransaction(tx)
    .on('transactionHash', function(hash) { resolve(hash); })
    .on('error', function(err) { reject(err); })
  })
}

Hi !
I have the same error when I'm using TransactionObject call method.

Does anyone have a solution ?
I'm on beta.28

I'm seeing the same behavior with beta.28 as well. I'm merely calling "estimateGas" and it's showing warning in logs. Should we open a new issue or reopen this one?

I'm also seeing this error with beta.30. Trying to integrate web3 with redux-saga.
Always happens when I use the method for the second time.

I've finded a workaround, working with Observables : (I will explain more if it's needed)

public getSomething(): Observable<any> {
    const contract = new web3.eth.Contract(...);
    const getSomething = contract.methods.getSomething();
    const resp: (v1?: Tx) => Observable<any> = Observable.bindNodeCallback(getSomething['call']);
    return resp();
}

Warnings dissapear with that.

Was this page helpful?
0 / 5 - 0 ratings