What if one of your script functions has a bug that causes endless (not terminating) execution, for example, an endless for loop and/or while loop. There are no remedies other than carefully examining the loop terminating statements.
Sometimes, your script may be flawless or bug free, but if it needs to handle a large spreadsheet or external data, it may take a long time to complete the execution. The maximum allowed time for your script to run continuously is 6 minutes. If it exceeds that limit, GAS would throw the "Exceeded maximum execution time" exception.
Tip
For a list of other limitations, please visit: https://developers.google.com/apps-script/guides/services/quotas#current_limitations.
To overcome this bottleneck, you can follow these steps. For example, if your doLengthyProcess
function takes a long time to finish, then manually create a minute's trigger for the doLengthyProcess
function so that it executes every 10 minutes...