Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 13a3629

Browse files
committed
Avoid rejecting a promise if listening on error
1 parent 9529e37 commit 13a3629

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/web3-core-method/src/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,10 @@ Method.prototype.buildCall = function() {
536536
return method.accounts.signTransaction(_.omit(tx, 'from'), wallet.privateKey)
537537
.then(sendSignedTx)
538538
.catch(function (err) {
539-
if (defer.eventEmitter.emit) {
539+
if (_.isFunction(defer.eventEmitter.listeners) && defer.eventEmitter.listeners('error').length) {
540540
defer.eventEmitter.emit('error', err);
541+
defer.eventEmitter.removeAllListeners();
542+
defer.eventEmitter.catch(function () {});
541543
}
542544
defer.reject(err);
543545
});

0 commit comments

Comments
 (0)