I have read similar questions such as Error type of "We're sorry, a server error occurred. Please wait a bit and try again. " and many others, but they were specific to other types of error.
I have a Google Apps Script running and processing Gmail emails with a minute timer.
Each day I receive logs by email with We're sorry, a server error occurred. Please wait a bit and try again.
(see screenshot #1 below). The problem is that:
there is no report of the line where the error happened, so it's hard to debug
it happens randomly every now and then, even if nothing happened at this precise time (there was no email to process), and 99.9% of the time, everything works without error. When there is no email to process, I can't see why this code can fail:
var mylabel = GmailApp.getUserLabelByName('emailstoprocess'); var threads = mylabel.getThreads(); for (var i = 0; i < threads.length; i++) { // do something }
in my scripts I don't call any external API, only Gmail API, and no time-consuming loop (especially when no new email is there: the script should do nothing). How can I have control over this
DEADLINE_EXCEEDED
error (see screenshot #2 below)? Indeed in the dashboard,Executions
page, I see:We're sorry, a server error occurred: DEADLINE_EXCEEDED
.
How to avoid this DEADLINE_EXCEEDED
error even if my script had did nothing at the time of the failure?
Or at least how to avoid receiving notifications each day about this?
do something
, fromWhen there is no email to process, I can't see why this code can fail:
, if the error occurs when the length ofthreads
is0
, for example, whenif (threads.length == 0) return;
is put after the line ofvar threads = mylabel.getThreads();
, what result will you obtain? – Tanaike