What does it mean «Too many simultaneous invocations: Spreadsheets at onOpen»

707 views
Skip to first unread message

Ihor Stefurak

unread,
May 19, 2020, 10:16:46 AM5/19/20
to Google Apps Script Community
Sometimes I see an error in my console with a message «Too many simultaneous invocations: Spreadsheets at onOpen». It looks like this is happening not because of my users did something. I've attached a screenshot that shows there is a large timeframe between user actions and this error.

My onOpen() code:

function onOpen(e) {
  SpreadsheetApp.getUi().createAddonMenu()
  .addItem('Start', 'showSidebar')
  .addToUi();
}

What can it be? How to debug it?
Знімок екрана о 17.09.33.png

Alan Wells

unread,
May 19, 2020, 10:21:00 AM5/19/20
to Google Apps Script Community
Is the spreadsheet shared?  Could there there be multiple users all opening the spreadsheet at the same time?

Faustino Rodriguez

unread,
May 20, 2020, 9:58:56 AM5/20/20
to Google Apps Script Community
I don't know what it means, but I am getting that error in the GCP (stackdriver error reporting) since last Feb.28
- It is for a public Sheets add-on
- In the last 30 days has affected 139 users 534 times
- see the screenshot attached 
- by the way, the second error in that screenshot ("You do not have access to perform that action. Please ask the owner of this item to grant access to you.") started on last Apr.21 ... no idea either
- our onOpen function has a single line and only creates the add-on menu

Screenshot from 2020-05-20 09-54-04.png



On Tuesday, May 19, 2020 at 10:16:46 AM UTC-4, Ihor Stefurak wrote:

Ihor Stefurak

unread,
May 21, 2020, 5:55:39 AM5/21/20
to Google Apps Script Community
The error is from the console.log tracker for my add-on.

Ihor Stefurak

unread,
Jun 24, 2020, 3:13:06 AM6/24/20
to Google Apps Script Community
Does anyone have something to add to the topic? It keeps posted to my console with no reason, I don't know where to look at.

Andrew Roberts

unread,
Jun 24, 2020, 5:27:58 AM6/24/20
to google-apps-sc...@googlegroups.com
Is your add-on published and verified? 

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/259e5484-95a5-4e71-801a-4e381bfe83efo%40googlegroups.com.

Andrew Roberts

unread,
Jun 24, 2020, 5:43:44 AM6/24/20
to google-apps-sc...@googlegroups.com
I'd be interested to hear any findings you have on this. I've been seeing the same error and I am wondering if it is because my add-on seems to have lost verification status, and maybe it is hitting a cap somewhere.

Monique Szpak

unread,
Jun 24, 2020, 6:39:42 AM6/24/20
to Google Apps Script Community
Interesting, one of my published add-ons has also mysteriously fallen into OAuth limbo. I'm not getting any error notifications but I received this email yesterday:
Dear Developer,
As part of our constant efforts to improve Google’s OAuth application ecosystem, we have launched additional protections to prevent malicious applications from spreading. Apps requesting risky OAuth scopes that have not  completed the OAuth developer verification process are limited to 100 new user grants.
Your Google Cloud/APIs project [my project] associated with Apps Script https://script.google.com/d/blahblahblah/edit has not completed this process and has reached 60% of this user limit. After this limit is exceeded, new users will be blocked from allowing your app to access their data until you complete the OAuth developer verification process. 
I would imagine you would also get such an email from Google (although I wouldn't bet on it). 

Btw it was published 11th April, no changes since then and the OAuth consent screen says: "Verification status - Being verified". The really odd thing is that it has a sister project (docs/sheets) with 95% identical code/scopes which was published at the same time and yet it is happily verified. Google moving in mysterious ways again.

(Sorry for off-topic post but "lost verification status" piqued my interest)

Ihor Stefurak

unread,
Jun 24, 2020, 7:51:57 AM6/24/20
to Google Apps Script Community
My add-on is published. «Hitting a cap» can be a reason. Does anyone knows how to identify the source of the problem
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.

Ihor Stefurak

unread,
Jun 24, 2020, 7:52:20 AM6/24/20
to Google Apps Script Community
It's out of the topic. Please start another one.

Faustino Rodriguez

unread,
Jul 6, 2020, 9:28:51 AM7/6/20
to Google Apps Script Community
Any updates on this topic/issue?
- I am still seeing plenty of that message in the stackdrive error console
- Is there any entry in the issue tracker about this?

Faustino Rodriguez

unread,
Jul 13, 2020, 11:06:26 AM7/13/20
to Google Apps Script Community
Could somebody in this thread / group help on explaining this issue to Google?
- I created a new issue in the tracker this morning about what it is been discussed in this conversation
- But Google said "Won't Fix (Intended Behavior)"

I am afraid I couldn't explain myself in a clear way or I was misunderstood
- I do believe it is an issue
- Unless they mean that a published Google Editor add-on script cannot be accessed by more than 30 users simultaneously ... I hope that's not the case.

Thanks in advance for your help on this
Fausto

Steve Webster

unread,
Jul 13, 2020, 11:13:41 AM7/13/20
to google-apps-sc...@googlegroups.com
Could you share all global variables (check all script files) and any onEdits even though the error is thrown on the onOpen event line item?
Are there any custom functions?
I wonder if an add-on customer has a Google Sheet with a lot of editors working at the same time. Not sure how to check that.

Kind Regards,

Steve Webster
SW gApps LLC, President 
GDE (Google Developer Expert)
Google Product Expert in: Google Apps Script, Drive, and Docs 
Google Vendor (2012-2013) || Google Apps Developer Blog Guest Blogger 
Add-ons: Text gBlaster 


--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.

Faustino Rodriguez

unread,
Jul 13, 2020, 11:30:22 AM7/13/20
to Google Apps Script Community
Thanks Steve
- there is no global variables other that a few global strings (e.g. var version = "3.3.217";)
- there is no onEdits
- there is no custom functions, it is a published (in the GSM) Google Sheets add-on
- no idea what the users are doing/getting on their side when this error happens, I have got no feedback on this error from any user
- the error started reporting in Stackdriver last Feb.28 and in the last 30 days affected 128 users, 1423 times

Otherwise, I cannot understand (the meaning) Google's answer in the tracker

Alan Wells

unread,
Jul 13, 2020, 12:16:42 PM7/13/20
to Google Apps Script Community
You can catch the error in your onOpen() function, then get the user key and log the user key to Stackdriver.


function onOpen() {
try{
  //Open menu

}catch(e){
  console.log("Error: " + e + " " + Session.getTemporaryActiveUserKey());

}
}

Then compare the user keys and time stamps.  If the user keys are different, then you've got different users triggering the function at the same time.
If this truly is a bug, then in order to prove it to Google, you will need some kind of proof.
And more information from the Stackdriver log may be the only way to prove anything.
For them to try to reproduce a situation where there are many users accessing the same spreadsheet at the same time is probably more work than they want to do.
Hopefully you can either prove to yourself that it's a bug, or it's intended behavior.
Getting accurate information is dependent upon whether the "catch" runs no matter what.
Even if the main block of code in the onOpen() fails, if the catch block runs and logs the error every time that there's an error,
then you'll have data with timestamps to tell you how many times the function ran in a period of time, and whether there are lots
of unique users, or the same user getting the same error over and over again.

That's about the best idea that I can come up with.
But, I'm open to any other ideas.

Faustino Rodriguez

unread,
Jul 13, 2020, 1:58:25 PM7/13/20
to Google Apps Script Community
Thanks Alan, that's an excellent idea
- only catching/logging the error will not add more information than I already have
- Stackdriver is already logging those errors using the temporary key, so I know how many errors/users at any given time

However,
- logging the successful onOpen will give me context about the simultaneous invocations to the Script (add-on)
- I mean, how many (error and no-error) are opening the add-on simultaneous when an error gets logged
- Still to learn how many seconds window is considered "simultaneous" invocations

Anyway,
- Do you believe that a published add-on script only allows for 30 simultaneous users opening the add-on ...?
- What would be happening with the several million users add-on ?
- Are they getting this error as well?

Thanks again, as usual.

Alan Wells

unread,
Jul 13, 2020, 2:27:07 PM7/13/20
to Google Apps Script Community
The add-on is subject to the quota limitations of the account that installed it.
That is different than how many users have installed your add-on.
There's a difference between individual add-on installations, and the number of users for a document.
Millions of Google accounts can install your add-on.
Theoretically, an indefinite number of users can install and use your add-on.
But that's different than the quota limits placed on the individual account.

If a particular Google account installed your add-on to their spreadsheet,
AND that spreadsheet is shared with lots of other users,
from the account that installed it, then all those users are going to use up the quota limits
for the account that installed the add-on.
The account that installed the add-on doesn't' get extra special quota limits because it's an add-on.

As far as quota limits are concerned, your add-on code runs exactly the same as if the account that
installed the add-on was actually running the code as their code.
Actually, I'm guessing that a copy of your add-on code (or something like that) is probably running exactly the same as if
the user was running if from their account.

Sometimes people contact me, asking why they are hitting the 100 recipient email limit on an free/consumer account
when they have my add-on installed.
Then I've got to explain to them that I don't work for Google, and payment for my add-on isn't payment for a GSuite account.
If, for example, you gave the user a copy of your add-on code, and they ran it from their account, and that code hit the quota limit,
then your add-on will hit the same quota limit.

Faustino Rodriguez

unread,
Jul 13, 2020, 3:47:56 PM7/13/20
to Google Apps Script Community
I hope you are right on not having a limit in the number of users simultaneous accessing the add-on
- I least that's my expectation

I'll keep this conversation posted on any updates

I hope somebody around having the same issue, bring some more light into this

Faustino Rodriguez

unread,
Jul 14, 2020, 3:28:21 PM7/14/20
to Google Apps Script Community
I haven't done (needed) a deep logging/debugging in Stackdrive logging before, it is a great tool now that I needed ... thanks for the suggestions
I ended up with this onOpen function
`function onOpen(e) {
  try {
    SpreadsheetApp.getUi().createAddonMenu()
    .addItem("Start Mapping", 'vueSidebar')
    .addItem("Preferences", 'vuePreferences')
    .addItem("Subscription", 'vueSubscription')
    .addSeparator()
    .addItem('About', 'vueAbout')
    .addToUi();
    console.log("Spreadsheets successful call at onOpen()");
  } catch(e) {
    console.error(e);
  }
}`
- no need to include the Session.getTemporaryActiveUserKey(), it is always added by console.log/error etc

On reading the Log for the last 6 hours
- 19 errors (Too many simultaneous invocations: Spreadsheets at onOpen) for 12 users. Some of them wait a bit and tried again
- I am almost sure that many users are not calling 30 scripts simultaneously from their accounts

However the 30 Simultaneous executions limit as mentioned on this page
- it makes sense (from reading the Log) if it means 30 Simultaneous executions on the same script from different users
- that is because when looking back in the Log from one of these errors, I found that the 30 previous successful calls happened in around 10 secs

By the way, I had no idea of that many users in such short period of time

Not sure how to deal with this issue from now on ...

Any feedback is welcomed

Alan Wells

unread,
Jul 14, 2020, 3:41:51 PM7/14/20
to Google Apps Script Community
Glad that you got some good data.
I don't know if using LockService would do anything in this situation.
But, it might be interesting to try it and see what happens.

Ihor Stefurak

unread,
Jul 30, 2020, 10:47:00 AM7/30/20
to Google Apps Script Community
Even more. Now I see some random "Error detected" message...

Знімок екрана  о 17.45.05.png

Faustino Rodriguez

unread,
Jul 30, 2020, 3:37:26 PM7/30/20
to Google Apps Script Community
I believe, that "Error detected" message shows in the Log for the first error that happens on a recent published version
In that case first error detected on version 164

Andrew Apell

unread,
Aug 4, 2020, 1:51:57 AM8/4/20
to Google Apps Script Community
I see this for my add-on aw well. I just assumed that many people sharing the same email have opened a spreadsheet at the same time...
Reply all
Reply to author
Forward
0 new messages