Skip to content

Commit 01276fd

Browse files
committed
Capture eventual userland error handling tx error
Since the event handlers are run syncronously, if an `error` event handler thows, the error will return to the lib and keep the promise chain broken, rising an unhandled promise rejection error. Resolves web3#3708
1 parent 62cb124 commit 01276fd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,11 @@ Method.prototype.buildCall = function () {
729729
.then(sendSignedTx)
730730
.catch(function (err) {
731731
if (_.isFunction(defer.eventEmitter.listeners) && defer.eventEmitter.listeners('error').length) {
732+
try {
732733
defer.eventEmitter.emit('error', err);
734+
} catch (err) {
735+
// Ignore userland error prevent it to bubble up within web3.
736+
}
733737
defer.eventEmitter.removeAllListeners();
734738
defer.eventEmitter.catch(function () {
735739
});

0 commit comments

Comments
 (0)