fix: end the session when dial's actionHook returns nothing usable

An empty array, a non-array body, or a non-json content-type all resolve
rather than throw, so performAction returns false and the session was left
parked. A hook that answered with no verbs is no better a reason to hold the
caller than one that failed.

Deliberately overrides the ws "ack now, send verbs later" pattern for dial:
an app that means to push verbs afterwards must return them from the hook.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
xquanluu
2026-08-26 17:30:13 +07:00
co-authored by Claude Opus 5
parent 20210563f9
commit 1d35ced55b
+6 -1
View File
@@ -252,7 +252,12 @@ class TaskDial extends Task {
this.logger.debug({callSid: this.cs.callSid}, 'Dial:exec task is done, sending actionHook if any');
if (this.actionHook) hookAttempted = true;
else this._endSessionUnlessHandedOff(cs, 'dial completed with no actionHook');
await this.performAction(this.results, this.killReason !== KillReason.Replaced);
const gotVerbs = await this.performAction(this.results, this.killReason !== KillReason.Replaced);
/* hook answered but with nothing usable: empty array, a non-array body, or a
non-json content-type, none of which throw */
if (hookAttempted && gotVerbs === false) {
this._endSessionUnlessHandedOff(cs, 'dial actionHook returned no verbs');
}
this._removeDtmfDetection(cs.dlg);
this._removeDtmfDetection(this.dlg);
this._removeSipIndialogRequestListener(this.dlg);