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 <matt.preskett@netcall.com>
This commit is contained in:
two56
2023-05-11 15:17:39 +01:00
committed by GitHub
parent 3b6c103618
commit eb1e0d3bf5

View File

@@ -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);
}
}