diff --git a/lib/session/call-session.js b/lib/session/call-session.js index d7c17298..6166fd4b 100644 --- a/lib/session/call-session.js +++ b/lib/session/call-session.js @@ -529,7 +529,7 @@ class CallSession extends Emitter { this.logger.info({currInput, newInput}, 'CallSession:enableBotMode - restarting background gather to apply new input type'); this.backgroundGatherTask.sticky = false; - this.disableBotMode(); + await this.disableBotMode(); } } this.backgroundGatherTask = task; @@ -568,12 +568,12 @@ class CallSession extends Emitter { this.logger.info({err, gather}, 'CallSession:enableBotMode - Error creating gather task'); } } - disableBotMode() { + async disableBotMode() { this._bargeInEnabled = false; if (this.backgroundGatherTask) { try { this.backgroundGatherTask.removeAllListeners(); - this.backgroundGatherTask.kill().catch((err) => {}); + await this.backgroundGatherTask.kill(); } catch (err) {} this.backgroundGatherTask = null; } @@ -724,7 +724,7 @@ class CallSession extends Emitter { } else { this.logger.info('CallSession:exec disabling bot mode to start gather with new options'); - this.disableBotMode(); + await this.disableBotMode(); } } if (!skip) {