Exception: Service Spreadsheets failed while accessing document with id

543 views
Skip to first unread message

Philip Pappas

unread,
Dec 28, 2022, 9:39:21 AM12/28/22
to Google Apps Script Community
I have a function that is triggered every hour by the built in triggers in Google App Script.
it works perfectly but it just threw this error

"Exception: Service Spreadsheets failed while accessing document with id "

i haven't changed anything in the code though so i don't really know what could be causing this. it has been working for days with no problem, so this was a surprise.

I thought this might have something to do with the time restrictions from Google. 6 minutes is the limit if i remember correctly.

I have around 5 more functions that get triggered independently by different triggers every hour. Each of those functions takes from 5 seconds to 30 seconds, so could this be the issue here?

The 6 minute limit is per function?
so all 6 of my functions have a limit of 6 minutes each?
even if they get triggered around the same time?

Again, i am not sure this is a time related issue or a bug. But i can't imagine my code being the issue here cause i ve been using this script for months with the tirgger

i would appreciate any tips and ideas

Kind Regards,
Philip

Alex

unread,
Dec 29, 2022, 1:15:24 AM12/29/22
to Google Apps Script Community

In rare cases your file may be locked by another process for a long time. This may cause access problems. But this may not happen often. Unless you have a very large file, for example you are processing 50K lines.

Philip Pappas

unread,
Dec 30, 2022, 7:55:59 AM12/30/22
to Google Apps Script Community
Is there a way to check for this and have my triggers run one at a time?
Or more like when a trigger triggers a function that function could check if there is another process running already and then wait until it is complete in order run.
I have some hourly triggers that might be running too close to each other, but there isn't an option to set the start time of each hourly trigger. So that every trigger for example starts 10 minutes after the other so that they wont bump to each other.

Alex

unread,
Dec 31, 2022, 2:59:36 AM12/31/22
to Google Apps Script Community
Hmm...

You can try LockService. Use waitLock for standing into running https://developers.google.com/apps-script/reference/lock/lock#waitLock(Integer)

Philip Pappas

unread,
Jan 4, 2023, 2:43:12 AM1/4/23
to Google Apps Script Community
interesting! i will look into that thank you
Reply all
Reply to author
Forward
0 new messages