在 Google Apps 脚本上运行异步函数

Per*_*me. 5 asynchronous google-apps-script async-await webassembly

我正在尝试在新的 V8 Google Apps Script 运行时上运行 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)
}
Run Code Online (Sandbox Code Playgroud)

当我运行test“正在运行的函数...”被记录时,然后什么都没有。没有错误,没有结果。我已经确认WebAssembly.instantiate返回一个 Promise。有谁知道发生了什么,或者这是要问谷歌的事情吗?

更新:

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

Iam*_*hus 4

V8 似乎还没有完全支持异步功能。实际上有一个关于此的开放问题跟踪器。您可以点击页面左上角的星号来跟踪此问题。

无论如何,请注意,官方文档中没有明确声明V8 中这些功能的可用性。它只是指出您可以像async在代码中一样使用关键字,但没有提到如果使用它您将获得什么功能。

参考: