From ca76f7691a00eaeb118e324ed6296125f22917a9 Mon Sep 17 00:00:00 2001 From: Gabriel Montes Date: Thu, 22 Nov 2018 23:34:24 -0300 Subject: [PATCH] Avoid rejecting a promise if listening on error --- packages/web3-core-method/src/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/web3-core-method/src/index.js b/packages/web3-core-method/src/index.js index d08c4977918..efe8fd974a7 100644 --- a/packages/web3-core-method/src/index.js +++ b/packages/web3-core-method/src/index.js @@ -536,8 +536,10 @@ Method.prototype.buildCall = function() { return method.accounts.signTransaction(_.omit(tx, 'from'), wallet.privateKey) .then(sendSignedTx) .catch(function (err) { - if (defer.eventEmitter.emit) { + if (_.isFunction(defer.eventEmitter.listeners) && defer.eventEmitter.listeners('error').length) { defer.eventEmitter.emit('error', err); + defer.eventEmitter.removeAllListeners(); + defer.eventEmitter.catch(function () {}); } defer.reject(err); });