mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
bugfix for race condition where incoming call canceled quickly leading to potential endless loop
This commit is contained in:
@@ -8,6 +8,7 @@ const makeTask = require('../tasks/make_task');
|
|||||||
const normalizeJambones = require('../utils/normalize-jambones');
|
const normalizeJambones = require('../utils/normalize-jambones');
|
||||||
const listTaskNames = require('../utils/summarize-tasks');
|
const listTaskNames = require('../utils/summarize-tasks');
|
||||||
const BADPRECONDITIONS = 'preconditions not met';
|
const BADPRECONDITIONS = 'preconditions not met';
|
||||||
|
const CALLER_CANCELLED_ERR_MSG = 'Response not sent due to unknown transaction';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @classdesc Represents the execution context for a call.
|
* @classdesc Represents the execution context for a call.
|
||||||
@@ -497,8 +498,15 @@ class CallSession extends Emitter {
|
|||||||
|
|
||||||
return ep;
|
return ep;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.logger.error(err, `Error attempting to allocate endpoint for for task ${task.name}`);
|
if (err === CALLER_CANCELLED_ERR_MSG) {
|
||||||
throw new Error(`${BADPRECONDITIONS}: unable to allocate endpoint`);
|
this.logger.error(err, 'caller canceled quickly before we could respond, ending call');
|
||||||
|
this._notifyCallStatusChange({callStatus: CallStatus.NoAnswer, sipStatus: 487});
|
||||||
|
this._callReleased();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.logger.error(err, `Error attempting to allocate endpoint for for task ${task.name}`);
|
||||||
|
throw new Error(`${BADPRECONDITIONS}: unable to allocate endpoint`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user