Skip to content

Commit

Permalink
fix(AsyncQueue): call the callback only if it's a function (jitsi#2370)
Browse files Browse the repository at this point in the history
  • Loading branch information
athouary committed Dec 5, 2023
1 parent 7841a38 commit d9c708d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions modules/util/AsyncQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ export default class AsyncQueue {
*/
clear() {
for (const finishedCallback of this._taskCallbacks.values()) {
try {
finishedCallback(new ClearedQueueError('The queue has been cleared'));
} catch (error) {
logger.error('Error in callback while clearing the queue:', error);
if (typeof finishedCallback === 'function') {
try {
finishedCallback(new ClearedQueueError('The queue has been cleared'));
} catch (error) {
logger.error('Error in callback while clearing the queue:', error);
}
}
}
this._queue.kill();
Expand Down

0 comments on commit d9c708d

Please sign in to comment.