From 4723de9b243a7ea2b86b62645ce6e3de7314a0d9 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Tue, 3 Jan 2023 13:16:54 -0500 Subject: [PATCH] further fix for race condition in #206 --- lib/tasks/gather.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/tasks/gather.js b/lib/tasks/gather.js index 5b2430a8..5687e5ed 100644 --- a/lib/tasks/gather.js +++ b/lib/tasks/gather.js @@ -191,6 +191,10 @@ class TaskGather extends Task { if (this.input.includes('speech') && !this.listenDuringPrompt) { this._initSpeech(cs, ep) .then(() => { + if (this.killed) { + this.logger.info('Gather:exec - task was quickly killed so do not transcribe'); + return; + } this._startTranscribing(ep); return updateSpeechCredentialLastUsed(this.sttCredentials.speech_credential_sid); }) @@ -223,7 +227,13 @@ class TaskGather extends Task { if (!this.killed) startListening(cs, ep); }); } - else startListening(cs, ep); + else { + if (this.killed) { + this.logger.info('Gather:exec - task was immediately killed so do not transcribe'); + return; + } + startListening(cs, ep); + } if (this.input.includes('speech') && this.listenDuringPrompt) { await this._initSpeech(cs, ep);