Multiple Accounts Bug ... Why does it fail for some plugins and not for others?

86 views
Skip to first unread message

Jesse McCabe

unread,
Feb 12, 2023, 10:00:35 AM2/12/23
to Google Apps Script Community

For years, my add-on has been a victim of this bug:


I can reproduce it by logging into two accounts in my browser and trying to run the add-on (Doc Variables) from the second account.  Yesterday, I tested other add-ons with the same context, some fail and others didn't.

I found two open-source add-ons that I could look at the code to compare and didn't see anything different in how they implemented their calls.

My function (that throws an error):

    var doc;
    try {      
      doc = DocumentApp.getActiveDocument();
    } catch (ex) {      
      throw new Error("Error loading Active Document.");      
    }
    return doc;


Their's (that work fine):

function getSelection() {
  var selection = DocumentApp.getActiveDocument().getSelection();

and

    try {
      doc = DocumentApp.getActiveDocument();
    } catch(e) {
      return 'ERROR opening active document: ' + e + '\n\n';
    }


Has anyone dug into this issue more?  Is there a known workaround now?

Thank you for any help,
Jesse

DimuDesigns

unread,
Feb 13, 2023, 12:27:55 PM2/13/23
to Google Apps Script Community
There is no known workaround unfortunately. Best you can do is to advise your end-users to not login into multiple accounts or better yet encourage them to maintain separate chrome profiles for each of their accounts and only log into one account per profile.

Jesse McCabe

unread,
Feb 13, 2023, 12:52:18 PM2/13/23
to Google Apps Script Community
Thanks, I figured I would have heard if there was a fix.  And I have done everything I can do to give notifications to users, but that doesn't prevent people from leaving bad reviews saying it doesn't work.

However, I am still confused that some plugins work and some don't with pretty much the same code...

Andrew Roberts

unread,
Feb 13, 2023, 1:56:57 PM2/13/23
to google-apps-sc...@googlegroups.com
I think there are instances where the move to v8 has made things worse. Similar "issues" on the tracker suggest going back to Rhino.

--
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/54a7b3ae-c1b7-4e6a-8a3b-34dccb0fa940n%40googlegroups.com.

Jesse McCabe

unread,
Feb 13, 2023, 2:24:10 PM2/13/23
to Google Apps Script Community
Is it even possible to go back to Rhino now?  I do think the add-ons I saw it working with have not had updates in quite a while... I wonder if that's part of it.

Andrew Roberts

unread,
Feb 14, 2023, 3:04:24 AM2/14/23
to google-apps-sc...@googlegroups.com
In the script editor's "Settings" you can disable V8, which forces it back to Rhino (and adds a new item in the appscript.json).  

Reply all
Reply to author
Forward
0 new messages