AppsScriptPulse

Programmatically handle long running Google Sheets tasks with Google Apps Script

 

Image credit: Sourabh Choraria

An approach to process hundreds of thousands of rows of data (say, on Google Sheets) without running into the script execution timeout error.

TL;DR — the typical challenge we face with tasks that take longer to execute is that of running into the execution timeout error (that’s at 6 minutes — Script runtime — as of 10-Feb-2023) and this article … elaborates on how to bypass script execution timeout with a detailed example.

As noted in this post by Sourabh Choraria the Apps Script runtime limit can be a bit of a challenge. If you’re encounter problems my first tip would be review your script and see what you can optimize. A common problem I often see in Google Sheets is using .getValue()/.setValue() (singular) not  .getValues()/.setValues()  (plural).

If even with script optimization you are still having issues Sourabh provides a very adaptable ‘design pattern’ for Google Sheets. The pattern is one I can personally relate too and very similar to the approach I used in my own projects. The source post has everything you need to try this out for yourself.

Source: Programmatically handle long running tasks in Apps Script

Leave a Reply

Your email address will not be published. Required fields are marked *