This Twilio product is currently available as a beta release. Some features are not yet implemented and others may be changed before the product is declared as Generally Available. Beta products are not covered by a Twilio SLA. Learn more about beta product support.
There are two possible reasons why your Function has completed with the error: 'runtime application timed out'.
The most common reason is that your Function has exceeded the 10-second execution time limit. You can determine this by looking at the execution logs on the Function instance page. The last log line after execution will tell you how many milliseconds the Function took to execute. If the processing time is greater than 10,000 milliseconds then your Function was terminated by Twilio.
The other more subtle reason your Function ended with an application timeout is because of an incorrect invocation of
callback(). If the
callback() method is not being called or is unreachable, your Function will continue executing until it reaches the time limit and ultimately fails. A very common mistake is to forget to capture the
catch() rejected state of a
Promise and calling
callback() there as well. The Function Execution documentation provides extensive details on the functionality and usage of the
callback() method. Below are several examples of how to correctly use
callback() to complete execution and emit a response.
The most common reason we have seen that a Function appears not to run is the misuse of
callback(). Your Function invocation terminates as soon as the
return callback() is reached. If your request is asynchronous, for example, an API call to a Twilio resource, then the
return callback() must be placed inside the success response of the request.
Function内臓のTwilio Nodeライブラリーを使用してVoice TwiMLを生成できます。
No, you cannot interact with the pre-flight OPTIONS request that is sent by browsers.
The Runtime client will automatically respond to
OPTIONS requests with the following values:
Access-Control-Allow-Origin: * Access-Control-Allow-Headers: * Access-Control-Allow-Methods: GET, POST, OPTIONS
This means that all origins are allowed to access your Function, all headers are passed through, and that only GET, POST, and OPTIONS requests are allowed methods to your Function.
You can send CORS headers by using the Twilio Response object described in the Function Execution documentation.
Currently, Functions are event-driven and can only be invoked by HTTP.
During the beta period, we currently have a limit of 100 functions per account via the UI. To create more Functions, consider using the Functions and Assets API.
Functions are limited to 30 concurrent invocations - meaning that if you have more than 30 Functions being invoked at the same time, you will begin to see new Function invocations return with a 429 status code. To keep below the threshold optimize Functions to return as fast as possible - avoid artificial timeouts and use asynchronous calls to external systems rather than waiting on a large number of API calls to complete.
Yes. See this blog post for a description and samples on how to store files for one-off usage.
Are there any Twilio resources for learning Node.js?
- 5 Ways to Make HTTP Requests in Node.js using Async/Await