From 909727899d7854c8ad9a3ff28b2fae37493b7cd7 Mon Sep 17 00:00:00 2001 From: Hoan HL Date: Sun, 9 Nov 2025 17:00:01 +0700 Subject: [PATCH] adding log for issue freshdesk 1600 --- lib/session/call-session.js | 2 +- lib/tasks/play.js | 3 +++ lib/utils/sticky-event-emitter.js | 5 ++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/session/call-session.js b/lib/session/call-session.js index 58e7d2f9..0a71debe 100644 --- a/lib/session/call-session.js +++ b/lib/session/call-session.js @@ -78,7 +78,7 @@ class CallSession extends Emitter { this.callGone = false; this.notifiedComplete = false; this.rootSpan = rootSpan; - this.stickyEventEmitter = new StickyEventEmitter(); + this.stickyEventEmitter = new StickyEventEmitter(logger); this.stickyEventEmitter.onSuccess = () => { this.taskInProgress = null; this.stickyEventEmitter.destroy(); diff --git a/lib/tasks/play.js b/lib/tasks/play.js index acb6b7a6..5441a5a1 100644 --- a/lib/tasks/play.js +++ b/lib/tasks/play.js @@ -67,6 +67,9 @@ class TaskPlay extends Task { this.logger.debug(`Play got kill-playback, executing uuid_break, taskId: ${t?.taskId}`); this.ep.api('uuid_break', this.ep.uuid).catch((err) => this.logger.info(err, 'Error killing audio')); this.notifyStatus({event: 'kill-playback'}); + } else { + this.logger.debug( + `Play received uuid_break for different taskId: ${t?.taskId}, current taskId: ${this.taskId}`); } }); }); diff --git a/lib/utils/sticky-event-emitter.js b/lib/utils/sticky-event-emitter.js index fc38cb03..b15a98ee 100644 --- a/lib/utils/sticky-event-emitter.js +++ b/lib/utils/sticky-event-emitter.js @@ -13,10 +13,11 @@ const EventEmitter = require('events'); * - Maintains compatibility with Node's EventEmitter interface */ class StickyEventEmitter extends EventEmitter { - constructor() { + constructor(logger) { super(); this._eventCache = new Map(); this._onceListeners = new Map(); // For storing once listeners if needed + this.logger = logger; } destroy() { this._eventCache.clear(); @@ -28,12 +29,14 @@ class StickyEventEmitter extends EventEmitter { this._eventCache.set(event, args); // If there are any 'once' listeners waiting, call them + this.logger.debug(`StickyEventEmitter emitting event: ${event} with args: ${JSON.stringify(args)}`); if (this._onceListeners.has(event)) { const listeners = this._onceListeners.get(event); for (const listener of listeners) { listener(...args); } if (this.onSuccess) { + this.logger.debug(`StickyEventEmitter calling onSuccess for event: ${event}`); this.onSuccess(); } this._onceListeners.delete(event);