From 1d35ced55b9e9bddffc973d117a6cdf9b179821f Mon Sep 17 00:00:00 2001 From: xquanluu Date: Wed, 26 Aug 2026 17:30:13 +0700 Subject: [PATCH] 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) --- lib/tasks/dial.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/tasks/dial.js b/lib/tasks/dial.js index d4f2e133..693dfc89 100644 --- a/lib/tasks/dial.js +++ b/lib/tasks/dial.js @@ -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);