"Request to Webtask exceeded allowed execution time" error in Rules

Problem statement

Sometimes we observe “Request to Webtask exceeded allowed execution time” issues in our production environment. Can you please help us to verify why this particular request raised this error?

Is there a way that we can troubleshoot such incidents?


  • “[Failed Exchange] Request to Webtask exceeded allowed execution time”


  • This error occurs whenever the total execution time for all rules exceeds 20 seconds


The first step is to track the execution time of your Rules. To do so, we recommend adding console.log() statements to each Rule to find which Rule(s) have a long execution time. See below:

function myRule(user, context, callback){
    console.log('RULE - ruleName : START *******');
    const startTime = new Date().getTime();
    console.log('start time: ', startTime);

    // your logic here

    const endTime = new Date().getTime();
    console.log('end time: ', endTime);
    console.log('Logic Excecution time: ', endTime - startTime);
    console.log('RULE - ruleName : END *******');

    return callback(null, user, context);

Then, use the Real-time Webtask Logs Extension to see these console.log() statements during an authentication flow. Here is a guide on how to view the logs: Real-time Webtask Logs Extension

With this information, we recommend reviewing and optimizing the Rule(s) suspected of a long execution time by following our documentation below on the best practices surrounding Rules execution: Rules Execution Best Practices

If you are making external API calls that are the source of the long execution time, there is an option to add a timeout to those calls and return a specific error code/message in the Rules Callback. This way, whenever the API call timeouts, you can view the errors in your tenant logs and prevent the “Request to Webtask exceeded allowed execution time” error message from occurring.

For example:

r = requests.post(url, data=payload, timeout=5)

Suppose you have 2 external API calls and considering the 20 seconds timeout, you can configure max timeout as 10 seconds for each external API call and return a specific error code/msg in the callback. Please avoid returning any sensitive information as this will be accessible through the logs.

Reference Materials:

1 Like