Google Sheet 加载项超时 ~ 45 秒?

Google Sheet Add-on timeout ~ 45 seconds?

我的 google Sheet 加载项在我通过 UI 触发一项功能后 45 秒后停止。我收到错误“超出最大执行时间”

我没想到会这样。我的理解是 google 应用程序脚本的最长时间应为 6 分钟。 google sheet 附加组件有什么不同吗?

为了调试,我已将我的脚本减少到最低限度,我的功能只是简单的休眠。这仍然在 45 秒后失败。 PS: 我的函数不在 onEdit 中。 感谢您的帮助

Code.gs

function onHomepage(e) {
  return createSelectionCard(e);
}
function createSelectionCard(e)
{
  var builder = CardService.newCardBuilder();
  builder.addSection(CardService.newCardSection()
    .addWidget(CardService.newButtonSet()
      .addButton(CardService.newTextButton()
        .setText('myfunction')
        .setTextButtonStyle(CardService.TextButtonStyle.FILLED)
        .setOnClickAction(CardService.newAction().setFunctionName('myfunction'))
        .setDisabled(false))));
  return builder.build();
}

function myfunction(e) {
  // this should pause for 1 minute, but breaks after 45 seconds
  Utilities.sleep(300000/5);
  return createSelectionCard(e)
}

appsscript.json

{
  "timeZone": "America/New_York",
  "dependencies": {},
  "exceptionLogging": "STACKDRIVER",
  "oauthScopes": [
    "https://www.googleapis.com/auth/spreadsheets.currentonly"
  ],
  "runtimeVersion": "V8",
  "addOns": {
    "common": {
      "name": "test",
      "logoUrl": "https://www.gstatic.com/images/branding/product/1x/translate_24dp.png",
      "layoutProperties": {
        "primaryColor": "#2772ed"
      },
      "homepageTrigger": {
        "runFunction": "onHomepage"
      }
    },
    "sheets" : {}
  }
}

UI: UI with just one button

当我点击我的函数时出现错误消息:

加载项出错。 运行时间错误。 超过最大执行时间

问题:

Card service, callback functions invoked by an Action中有30秒的执行时间限制:

Warning: The Apps Script Card service limits callback functions to a maximum of 30 seconds of execution time. If the execution takes longer than that, your add-on UI may not update its card display properly in response to the Action.

参考: