From dfe623e78a98e172a4562167647429c1e993d859 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Fri, 3 May 2024 12:53:26 -0400 Subject: [PATCH] Fix/google race condition gather (#743) * lint * logging * wip --- lib/tasks/gather.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/tasks/gather.js b/lib/tasks/gather.js index 9230feb1..834b0c0f 100644 --- a/lib/tasks/gather.js +++ b/lib/tasks/gather.js @@ -591,7 +591,6 @@ class TaskGather extends SttTask { } _killActionHookDelayAction() { - this.logger.debug('_killActionHookDelayAction'); if (this._actionHookDelaySayTask && !this._actionHookDelaySayTask.killed) { this._actionHookDelaySayTask.removeAllListeners('playDone'); this._actionHookDelaySayTask.kill(this.cs); @@ -1037,6 +1036,16 @@ class TaskGather extends SttTask { async _resolve(reason, evt) { this.logger.debug(`TaskGather:resolve with reason ${reason}`); + if (this.needsStt && this.ep && this.ep.connected) { + this.ep.stopTranscription({ + vendor: this.vendor, + bugname: this.bugname + }) + .catch((err) => { + if (this.resolved) return; + this.logger.error({err}, 'Error stopping transcription'); + }); + } if (this.resolved) return; this.resolved = true; @@ -1054,13 +1063,6 @@ class TaskGather extends SttTask { 'stt.resolve': reason, 'stt.result': JSON.stringify(evt) }); - if (this.needsStt && this.ep && this.ep.connected) { - this.ep.stopTranscription({ - vendor: this.vendor, - bugname: this.bugname - }) - .catch((err) => this.logger.error({err}, 'Error stopping transcription')); - } if (this.callSession && this.callSession.callGone) { this.logger.debug('TaskGather:_resolve - call is gone, not invoking web callback');