Stuck executions if I hangup during while the function is executing

622 views
Skip to first unread message

Carolyn Mallory

unread,
Sep 25, 2020, 2:51:09 PM9/25/20
to Twilio Functions
Hello, 

I have a studio flow that makes an outgoing call.  Once the phone is answered we ask the person to respond to a few prompts before the flow is complete.  I have noticed repeatedly that if I hang up the phone while a function is executing, the flow becomes stuck.  The function is pretty basic and just calls an api to update data in our database.  

I have configured the phone number so that the call status change and primary handler fails point to my studio flow.  The other thing I wonder about is that this flow was created over a year ago and I am not sure if maybe I have an old version of something that is the source of the issue.  

I did submit a support ticket but after I gave them my examples, I have not heard back.  I am going to production in a few weeks and really need this resolved.  Hopefully, someone has some ideas to prevent this other than manually checking for stuck executions several times a day.  Thanks!

Sam Kimbrel

unread,
Sep 25, 2020, 3:22:47 PM9/25/20
to Carolyn Mallory, Twilio Functions
Hi Carolyn,

Sorry for the delay with the support ticket!

I'd advise you to check two things in this case:

First, since you mentioned the flow was created a long time ago, you should ensure that "Allow Concurrent Calls" is enabled for the flow. You can view this in the flow editor by selecting the flow's trigger and looking under the Configuration tab where there is a checkbox for it.

Second, please check that your phone number's Status Callback and Fallback URLs are configured to route to the Studio flow. This helps ensure that Studio receives a final "hangup" event for the call and correctly terminates the flow.

Check out this FAQ entry about stuck executions for more information: https://support.twilio.com/hc/en-us/articles/360019383714-Understanding-and-Avoiding-Stuck-Executions-in-Twilio-Studio, and if you're still having problems with both of these settings correctly configured, please write back or follow up on the support ticket so we can take a closer look.

Cheers,

Sam Kimbrel
Principal Software Engineer
Pronouns: he/him/his
Twilio


--
You received this message because you are subscribed to the Google Groups "Twilio Functions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to twilio-functio...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/twilio-functions/d3cfb7ac-8024-40ba-84d5-127bfbf860e8n%40googlegroups.com.

Sam Kimbrel

unread,
Sep 25, 2020, 3:42:33 PM9/25/20
to Carolyn Mallory, Twilio Functions
On second read, I completely missed the "outgoing call" bit. My apologies for doing this while distracted by lunch...

For outgoing executions initiated via the REST API, you shouldn't need to worry about executions being stuck unless you need to make another call to the same contact. If you're using the V1 API, I suggest migrating to the V2 API (for Execution creation, it is identical) as the V2 Executions resource will respond with a 409 Conflict error if an execution is already in progress for the same contact. This error message will include the Sid of the existing open execution, which you can then terminate with the API (by making a POST request to the Execution instance with the Status=terminated parameter) before starting a new one.

Twilio will terminate and delete stuck Executions automatically after 60 days from the date they were initiated, and there is no ongoing cost associated with these executions being stuck. We continue to work to improve Studio's processing to help reduce the incidence of stuck executions.

My apologies again for misreading your original message and I hope this additional information helps.

Sam


Sam Kimbrel
Principal Software Engineer
Pronouns: he/him/his
Twilio

Carolyn Mallory

unread,
Sep 25, 2020, 4:52:43 PM9/25/20
to Twilio Functions
It does appear that I am using v1 for the Rest API URL and webhook.  Can I just change that to v2 and retest?


Sam Kimbrel

unread,
Sep 25, 2020, 5:20:27 PM9/25/20
to Carolyn Mallory, Twilio Functions
The webhook URLs will remain the same but in your call to the REST API to trigger a new Execution you can switch to v2 and retest. If you're using your own HTTP client, that will just mean replacing v1 with v2 in the URL; if you're working with one of the Twilio Helper Libraries there may be a change in the object or method to call to access the Studio resources. The v2 Execution API docs at https://www.twilio.com/docs/studio/rest-api/v2/execution have sample code for working with the helper libraries.

Sam Kimbrel
Principal Software Engineer
Pronouns: he/him/his
Twilio

Carolyn Mallory

unread,
Sep 27, 2020, 8:29:20 PM9/27/20
to Twilio Functions
I was using postman to test my flow.  I changed it to V2 in the URL and I still got the stuck execution.  I recreated the flow from scratch as the original flow was over a year old. I am testing it to see if I still get stuck executions but it seems better as I am not able to recreate issue.  I need to test when there is more of a load on our test system to be sure. 

Carolyn Mallory

unread,
Sep 28, 2020, 9:31:57 AM9/28/20
to Twilio Functions
I tried it again today with newly created flow and got a stuck execution.  We will need a workaround because the same phone number could get called at any time and this won't happen if there is a stuck execution. What is the best way to detect and then stop the executions in this scenario?
Message has been deleted

Alan

unread,
Sep 28, 2020, 1:40:41 PM9/28/20
to Twilio Functions
Hi Carolyn,

See the image below, this is the HTTP response you get when a Studio REST API trigger execution is already active and what Sam was referring to when using V2. Monitor for this response. The Studio Execution SID is under details, conflicting_execution_sid. You can then end the execution following the code examples shown in the documentation, End an Active Execution.


Since this feature is relatively new, added 4.15.2020, if you are using the Twilio Helper Libraries, make sure you are using a more current version. For example, for the Twilio Node.js helper library, this feature was added in 3.42.2 (Add Update Execution endpoints to v1 and v2 to end execution via API).

Alan
409Conflict.jpg

Kevin Fjelsted

unread,
Dec 31, 2020, 12:10:01 PM12/31/20
to Twilio Functions
I am attempting to install the Twilio CLI and the functions plugin.
I receive the enclosed error.
What do I need to do to resolve and use the correct version?
<<<twilio plugins:install @twilio-labs/plugin-serverless
warning @twilio-labs/plugin-serverless > @twilio/cli-core > ax...@0.19.2: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410
warning @twilio-labs/plugin-serverless > @twilio/cli-core > twilio > ax...@0.19.2: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410
warning @twilio-labs/plugin-serverless > twilio-run > chokidar > fsev...@2.1.3: Please update to v 2.2.x
warning @twilio-labs/plugin-serverless > twilio-run > ngrok > req...@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
warning @twilio-labs/plugin-serverless > twilio-run > ngrok > request-pro...@1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
warning @twilio-labs/plugin-serverless > twilio-run > ngrok > request > har-va...@5.1.5: this library is no longer supported
warning "@twilio-labs/plugin-serverless > @twilio/cli-core > twi...@3.54.1" has unmet peer dependency "@types/express@^4.17.7".
warning "@twilio-labs/plugin-serverless > @twilio/cli-core > twi...@3.54.1" has unmet peer dependency "@types/q...@6.9.4".
Installing plugin @twilio-labs/plugin-serverless... installed v1.8.0
>>>

akl...@twilio.com

unread,
Dec 31, 2020, 12:30:09 PM12/31/20
to Twilio Functions
Hi Kevin, 

Try reaching out (opening an issue) on this repo, I am sure they can help clarify what may be the problem.

Reply all
Reply to author
Forward
0 new messages