Skip to content

Commit

Permalink
Merge pull request #10055 from emrebass/patch-1
Browse files Browse the repository at this point in the history
Fix for 'ee.listeners' error
  • Loading branch information
vkarpov15 committed Mar 24, 2021
2 parents 1c20044 + 1629e4b commit 9e98cd8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/helpers/promiseOrCallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = function promiseOrCallback(callback, fn, ee, Promise) {
if (typeof callback === 'function') {
return fn(function(error) {
if (error != null) {
if (ee != null && ee.listeners('error').length > 0 && !error[emittedSymbol]) {
if (ee != null && ee.listeners != null && ee.listeners('error').length > 0 && !error[emittedSymbol]) {
error[emittedSymbol] = true;
ee.emit('error', error);
}
Expand All @@ -30,7 +30,7 @@ module.exports = function promiseOrCallback(callback, fn, ee, Promise) {
return new Promise((resolve, reject) => {
fn(function(error, res) {
if (error != null) {
if (ee != null && ee.listeners('error').length > 0 && !error[emittedSymbol]) {
if (ee != null && ee.listeners != null && ee.listeners('error').length > 0 && !error[emittedSymbol]) {
error[emittedSymbol] = true;
ee.emit('error', error);
}
Expand All @@ -42,4 +42,4 @@ module.exports = function promiseOrCallback(callback, fn, ee, Promise) {
resolve(res);
});
});
};
};

0 comments on commit 9e98cd8

Please sign in to comment.