Skip to main content

Hello there,

a script that is running as part of an automation is failing occasionally because it is exceeding the 30 seconds limit. This is out of my control because it is calling an external API which sometimes takes a bit longer due to high load (OpenAI API). This is the error message.

Script exceeded execution time limit of 30 seconds
How can I add retries after 60 seconds or so?
 
Cheers
Christoph
 

This is tricky because scripts do not have a way of tracking how much time has while waiting for the external API to respond. So you cannot have the script abort the call just before the 30 seconds are up and set a flag for the retry. You also don't really have a way to provide a callback for the response.

You could have a {script running} checkbox field that the automation checks just before running the script. Then if the script is successful, the automation clear the checkbox. Then a formula field that checks if the {script running} checkbox is selected and compares the last modified time with NOW(). Have that formula field trigger a second automation that triggers the scripting automation again. But the trigger for this automation will have a far longer delay than you will probably like because NOW() only updates every few minutes to every few hours. Plus, using NOW() is resource intensive.

Overall, I recommend looking for a solution that involves a third party service.


This is tricky because scripts do not have a way of tracking how much time has while waiting for the external API to respond. So you cannot have the script abort the call just before the 30 seconds are up and set a flag for the retry. You also don't really have a way to provide a callback for the response.

You could have a {script running} checkbox field that the automation checks just before running the script. Then if the script is successful, the automation clear the checkbox. Then a formula field that checks if the {script running} checkbox is selected and compares the last modified time with NOW(). Have that formula field trigger a second automation that triggers the scripting automation again. But the trigger for this automation will have a far longer delay than you will probably like because NOW() only updates every few minutes to every few hours. Plus, using NOW() is resource intensive.

Overall, I recommend looking for a solution that involves a third party service.


Thank you for your response @kuovonne,

That is a bit surprising. Wouldn't it be possible to add a line to the script that uses the error message as a trigger for the script to run again? Something like "If the response of the script is 'Script exceeded execution time limit of 30 seconds' try again"?

 

Cheers
Christoph


Thank you for your response @kuovonne,

That is a bit surprising. Wouldn't it be possible to add a line to the script that uses the error message as a trigger for the script to run again? Something like "If the response of the script is 'Script exceeded execution time limit of 30 seconds' try again"?

 

Cheers
Christoph


If the script exceeds execution time of 30 seconds, then the scripting action fails and the entire automation run stops mid-script. Once the script hit 30 seconds, the game is over. You don't get to run addition code that triggers the script to run again. You don't get to run a followup automation action that checks if the scripting action was successful. You either need to put the check on the automation status external to the automation itself, or have a way of checking on the status of the promise before it is resolved.

There are some interesting ways of getting the status of a promise that you can try searching for. Some won't work with Airtable because they require additional libraries. Others with .race look like they have potential, but I haven't use them and cannot say for sure if they will work.

Other automation platforms have better ways of dealing with when an automation fails but Airtable has not yet built that into its automation system.


Airtable offers you the ability to manually retry your failed automations, but there is no way for Airtable to automatically retry your failed automations.

Instead, your #1 best bet for this sort of problem is to outsource your automations to Make’s advanced automations & integrations for Airtable.

That’s because it solves both of your problems:

  1. It allows automatic retrying of failed automations, along with lots of other error handling.
  2. The execution timeout limit with Make is 40 minutes per automation.

And what’s really awesome about Make is:

  1. Make is a no-code platform, so you can create all sorts of advanced automations & app integrations without writing any code at all.
  2. But what’s even more exciting is that if you DO want to write your own Javascript code, that is natively supported by Make’s Code module.

If you’ve never used Make before, I’ve assembled a bunch of Make training resources in this thread. For example, here is one of the ways that you can instantly trigger a Make automation from Airtable

I also give live demonstrations of how to use Make in many of my Airtable podcast appearances. For example, in this video, I show how to work with Airtable arrays in Make.

Hope this helps!

If you’d like to hire the best Airtable consultant to help you with anything Airtable-related, please feel free to contact me through my website: Airtable consultant — ScottWorld