From eb1e0d3bf509e69c5f73e011d42f7faeb9d67d1c Mon Sep 17 00:00:00 2001 From: two56 Date: Thu, 11 May 2023 15:17:39 +0100 Subject: [PATCH] Fix: REST dial timeout (#351) * Fix #343 by cancelling the request if the session isn't available * Commit that works for 302's calls --------- Co-authored-by: Matt Preskett --- lib/tasks/rest_dial.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/tasks/rest_dial.js b/lib/tasks/rest_dial.js index 36289d33..61e0b700 100644 --- a/lib/tasks/rest_dial.js +++ b/lib/tasks/rest_dial.js @@ -28,6 +28,7 @@ class TaskRestDial extends Task { */ async exec(cs) { await super.exec(cs); + this.cs = cs; this.canCancel = true; this._setCallTimer(); @@ -37,9 +38,9 @@ class TaskRestDial extends Task { kill(cs) { super.kill(cs); this._clearCallTimer(); - if (this.canCancel && cs?.req) { + if (this.canCancel) { this.canCancel = false; - cs.req.cancel(); + cs?.req?.cancel(); } this.notifyTaskDone(); } @@ -98,7 +99,7 @@ class TaskRestDial extends Task { _onCallTimeout() { this.logger.debug('TaskRestDial: timeout expired without answer, killing task'); this.timer = null; - this.kill(); + this.kill(this.cs); } }