How much time script waiting response from server? [duplicate] - google-apps-script

This question already exists:
Exceeded maximum execution time in Google Apps Script [duplicate]
Closed 7 years ago.
My Google script, which I'm runnig from script.google.com invokes a PHP script on a remote server. This PHP script works for a few minutes, maybe more.
How much time can the Google script wait for a response from server?

Check this advice from Google.
We do not increase script execution times on a per-domain basis. There are ways for you to accomplish your use-case without any increases, however. Instead of trying to do everything in one script's execution time, use a sequence of script executions (using triggers) to process batches of the overall job. You can use ScriptDB or another persistent datastore to keep track of the documents processed, and each subsequent triggered execution can read from this and pick up processing where the previous execution left off.

Better than "waiting" for the response, is making the PHP call a new function on GAS (sorta like a callback), to do this publish your GAS with the options "As me" and "Anyone, even anonymous". Then you can call the /exec link with Get/Post parameters and continue executing the function.
This is ofcourse if your editor on the PHP page.

Related

Measure my current usage consumption on google app script

I have a google app script that execute the following actions:
Read a incoming webhook, write some information on a google spreadsheet, update a google contact and generates several outbound webhooks.
It takes aproximately 5 seconds to execute the whole script.
I would like to know how much times per day I can execute this script. I have seen the following web page but I am not sure in which feature my actions might fit, since there is no description of what those each feature means.
https://developers.google.com/apps-script/guides/services/quotas
Also I check in the google app script dashboard in hope I could find the current usage of my app script, but I only found that my script is execute 500 times per day for an average of 5 seconds per execution. In the future I am going to need to execute this app script more times, but I will like to know which is limit.
¿Where can I find my current app script consumption and which are the quotas for the features I am currently using?
As mentioned in the comments, Google Apps Script has a quota page that shows execution limits on various services.
Please note that you can get quota exception messages if you go near these limits but not go over them entirely.
Since you mentioned that you may need to execute your script more than 500 times a day, you might want to start optimizing your functions to take less time. You can start searching for resources on how to do this, for example in this post: Tracking total execution time Google apps script for an account

Is there anyway to Extend or allow configurable timeout for UrlFetchApp.fetch in Google Apps Script?

I am trying to build a Google Data Studio Connector, but I am facing a Google Apps Script timeout issue for UrlFetchApp.fetch(). Is there any way we can extend it or fix it, because it is breaking our reports.
It happens due to multiple calls to our API simultaneously.
is your script running for more than the typical 30 minutes allowed? I had a UrlFetch situation where the order of arguments impacted how long it took to run the script. And by modifying the order, we got our script to run in 2-3 minutes instead of timing out.

I am getting below email on daily basis. How to stop it?? Summary of failures for Google Apps Script: Eml Manager [duplicate]

This question already has answers here:
Summary of failures for Google Apps Script: Not found
(2 answers)
Closed 5 years ago.
I am getting below email on daily basis. How to stop it??
Summary of failures for Google Apps Script: Eml Manager
If you are not supposed to be running any scripts then you can just open the script editor, click on Resources → All Your triggers and then remove triggers you do not want. You can also simply disable notifications by clicking on the Notifications link to the right of the trigger and removing your e-mail.
Otherwise, in a similar manner, go to the Eml Manager and fix the code :)
If you are getting 'Summary of failures for Google Apps Script' on daily basis, you should look forward to fixing your code because code isn't behaving as you had expected.
Here are few of the reasons which can cause those failure emails:
Too many simultaneous invocations on the google app to which you have attached your appscript
Authorization or Authentication issue (a new user of the script has to authorize it first time)
Script took more than 6 minutes to complete (6 min is the limit)
If you have created programatical triggers, and forget to delete them once it has served the purpose, it will keep on creating new triggers and there is total trigger limit per script is 20.
In some cases, server can also be too busy to trigger your script but that rarely happens.
Also, if your script is taking too longer to complete, you should look forward to reducing the looping and also reducing writing operations on google apps(as it keeps on saving every change you made). Also, use in built formulas etc as much as possible.
If your code is totally fine according to you, then you can stop those failure emails by removing your name from the notifications option of your triggers as #Vytautas mentioned.

Google Sheets Add-on timed-trigger for a large data set

According to Google app script time-trigger documentation https://developers.google.com/apps-script/guides/triggers/installable#limitations,
Time-driven triggers cannot run more frequently than once per hour. How can I use app script to write an add-on that process large amount of data?
If I run a trigger, it will only allow me to trigger once. I can't chain the triggers so it can continuously run.
You cannot do so using triggers because they would run at most once per hour in the context of an add on.
What you can do is to initiate such processing client-side while possibly showing progress on a sidebar. The client js in the sidebar can chain server calls.Of course being all client-side means the user must have opened the file and if they close the browser tab or navigate away, the chain calls will stop. That can be handled by alerting the user and making them aware that a "sync" happens and sometimes takes a while. Currently there is no other way to handle this unless your client call and time trigger call another server which does the processing, like appengine or gce.

Google Apps Scripts Idle time

I am currently using Google Apps Scripts to create a Drive Addon, and I noticed that if I leave a page idle for some time, the script functionality no longer executes (e.g. calls to google.script.run -- frontend-only stuff still works as expected)
I'm wondering if there is an idle timeout for apps script and if so, what kinds of techniques should I use to handle it cleanly?
Thanks!
I've managed to isolate the problem to having something to do with the Cache service provided by Apps Script. I wasn't aware that there was an expiry time on cache objects and have set it now to the maximum 6 hours. The default expiration is 600 seconds (10 minutes).