1

I'm developing an application that take some Google Sheets to another Google Drive folder and then access each folder and fill an specific sheet for each folder. I'm receiving "Timeout Execution" and have read here at SO about dealing with it.

But I have a doubt, what does GAS consider as "Script" when talking about "Script runtime" ? Do they consider a Project, a File or a Trigger in this time limit ?

Cooper
  • 59,616
  • 6
  • 23
  • 54
André C. Rocha
  • 301
  • 5
  • 17
  • 1
    As I have come to understand it, it means a function that has been called but has not come to an end. If you start a function that calls other functions it waits for them to finish, as GAS is synchronous. So if the first function you called exceeds the time limit, it eventually fails. Lacking the official proof though, so it is an "I think" answer – FatFingersJackson Mar 28 '19 at 14:02
  • 1
    And what about creating triggers dinamically to avoid the Time Exceeded as explained here https://stackoverflow.com/questions/7854573/exceeded-maximum-execution-time-in-google-apps-script ?? – André C. Rocha Mar 28 '19 at 20:30
  • Most important is item 2 - Have your script terminate every five minutes or so. If you can chop your functions runtime to 5 minutes total, and still don't need to run 20 triggers a day, then you can use this strategy. – Celso Pereira Neto Mar 28 '19 at 21:08
  • I also can trigger, dynamically, another project, can't I ? If it's possible, this will allow me to "extend" this time execution limit. And what about 30 sec limit per function, also explained [here](https://developers.google.com/apps-script/guides/services/quotas) ? What do they mean about it ? – André C. Rocha Mar 29 '19 at 12:30
  • Hello, as for calling another project, I believe is feasible if your project is a standalone script, what is standalone and what is bounded is clarified in this link https://developers.google.com/apps-script/guides/bound The 30s limit is for custom functions, these are the functions you can create on spreadsheet-bounded projects and use them in Google sheets with the = before, as with built in functions like =sum() – Celso Pereira Neto Mar 29 '19 at 13:52
  • @AndréRocha please check again my answer. I think that makes your life easier since you only need to refactor the function causing trouble – Celso Pereira Neto Mar 29 '19 at 14:45

1 Answers1

1

As I done some testing I believe I should correct myself:

You should consider each function.

Here is the code I used for testing:

function one() {
    Utilities.sleep(200000) // 3,33 minutes 
    Logger.log("function one() finished execution");
}

function two() {
    Utilities.sleep(200000)
    Logger.log("function two() finished execution");
}

function three() {
    Utilities.sleep(200000)
    Logger.log("function three() finished execution");
}

function callEveryone(){
    one();
    two();
    three();
} 

Totaling around 10 minutes, callEveryone() runs just fine. Change 200000 to 366000 in any of the functions and the error occurs instantly.