From 724d4fb713dbcae370b4672bc46aa8ccae00e97d Mon Sep 17 00:00:00 2001 From: rammohan-y <37395033+rammohan-y@users.noreply.github.com> Date: Thu, 19 Sep 2024 19:59:51 +0530 Subject: [PATCH] Feat/893: Made noResponseTimeout and noResponseGiveUpTimeout independent (#896) * feat/893: made noResponseTimeout and noResponseGiveUpTimout independent * feat/893: not assuming 0 if noResponseTimeout is not specified --- lib/utils/action-hook-delay.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/utils/action-hook-delay.js b/lib/utils/action-hook-delay.js index 60efdd56..656f8a8f 100644 --- a/lib/utils/action-hook-delay.js +++ b/lib/utils/action-hook-delay.js @@ -2,7 +2,6 @@ const makeTask = require('../tasks/make_task'); const Emitter = require('events'); const { normalizeJambones } = require('@jambonz/verb-specifications'); const {TaskName} = require('../utils/constants'); -const assert = require('assert'); /** * ActionHookDelayProcessor @@ -51,7 +50,7 @@ class ActionHookDelayProcessor extends Emitter { this.actions = opts.actions; this.retries = opts.retries || 0; - this.noResponseTimeout = opts.noResponseTimeout || 0; + this.noResponseTimeout = opts.noResponseTimeout; this.noResponseGiveUpTimeout = opts.noResponseGiveUpTimeout; // return false if these options actually disable the ahdp @@ -66,11 +65,16 @@ class ActionHookDelayProcessor extends Emitter { this.logger.debug('ActionHookDelayProcessor#start: already started due to prior gather which is continuing'); return; } - assert(!this._noResponseTimer); this._active = true; this._retryCount = 0; - const timeoutMs = this.noResponseTimeout === 0 ? 1 : this.noResponseTimeout * 1000; - this._noResponseTimer = setTimeout(this._onNoResponseTimer.bind(this), timeoutMs); + if (this.noResponseTimeout > 0) { + const timeoutMs = this.noResponseTimeout * 1000; + this._noResponseTimer = setTimeout(this._onNoResponseTimer.bind(this), timeoutMs); + } else { + this.logger.debug( + 'ActionHookDelayProcessor#start: noResponseTimeout is 0 or undefined hence not calling _onNoResponseTimer' + ); + } if (this.noResponseGiveUpTimeout > 0) { const timeoutMs = this.noResponseGiveUpTimeout * 1000;