From 888fddff375dcb9ba53cae76948d39bed1b9b0aa Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Fri, 3 May 2024 08:55:16 -0400 Subject: [PATCH] possible fix for race condition in gather which ends but lets transcription continue --- lib/tasks/gather.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/tasks/gather.js b/lib/tasks/gather.js index 1c106836..a6448413 100644 --- a/lib/tasks/gather.js +++ b/lib/tasks/gather.js @@ -964,6 +964,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; @@ -981,13 +991,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');