【问题标题】:Running WebAssembly on Google Apps Script在 Google Apps 脚本上运行异步函数
【发布时间】:2020-07-26 04:25:34
【问题描述】:

我正在尝试在新的 V8 Google Apps 脚本运行时上运行 WebAssembly,它似乎受支持,但似乎异步函数在返回 Promise 后被终止。

let wasm= new Uint8Array([/* snip */]).buffer
function add(a,b) {
  return((async()=>{
  console.log("running function...")
  results=await WebAssembly.instantiate(wasm)
  return results.instance.exports.add(a,b)
})());
}
function test(){
  add(2,3).then(console.log).catch(console.error)
}

当我运行test“运行功能...”被记录,然后什么都没有。没有错误,没有结果。我已经确认WebAssembly.instantiate 返回了一个 Promise。 有谁知道发生了什么,或者这是要向 Google 询问的问题?

更新:

https://issuetracker.google.com/issues/153828715创建了一个问题

【问题讨论】:

  • 确保你的 snip 是一个有效的模块。如果是这样,请在 issuetracker 中创建一个问题。有关详细信息,请参阅tag info page
  • 确切的代码也适用于浏览器,所以它是有效的。
  • 如果您创建问题,请在此处链接以扩大影响范围

标签: asynchronous google-apps-script async-await webassembly


【解决方案1】:

V8 似乎还没有完全支持异步功能。实际上有一个open Issue Tracker 与此有关。您可以单击页面左上角的星号来跟踪此问题。

无论如何,请注意the official documentation 中没有明确声明提及这些功能在 V8 中的可用性。它只是说明您可以在代码中使用async 之类的关键字,但没有提及如果使用它会获得什么功能。

参考:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-13
    相关资源
    最近更新 更多