在 Google Apps 脚本上运行异步函数 [英] Running async functions on Google Apps Script
问题描述
我正在尝试在新的 V8 Google Apps Script 运行时上运行 WebAssembly,它似乎受支持,但似乎异步函数在返回 Promise 后终止.
I am attempting to run WebAssembly on the new V8 Google Apps Script runtime, and it appears to be supported, however it seems that async functions are terminated after they return a 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 的事情吗?
when I run test
"running function..." is logged, then nothing. No errors, no results. I have confirmed that WebAssembly.instantiate
returns a Promise.
Does anyone know what is going on, or is this something to ask Google about?
在 https://issuetracker.google.com/issues/153828715 创建了一个问题
推荐答案
V8 似乎还没有完全支持异步功能.实际上有一个关于此的开放问题跟踪器.您可以点击页面左上角的星星来跟踪此问题.
Asynchronous functionalities don't seem to be fully supported in V8 yet. There is actually an open Issue Tracker regarding this. You can click the star on the top left of the page to keep track of this issue.
无论如何,请注意 官方文档 指的是这些功能在 V8 中的可用性.它只是说明您可以在代码中使用诸如 async
之类的关键字,但并未提及如果使用它您将获得什么功能.
In any case, please be aware that there is no explicit statement in the official documentation referring to the availability of these functionalities in V8. It just states that you can use keywords like async
in your code, but it doesn't mention what functionality you will get if you use that.
这篇关于在 Google Apps 脚本上运行异步函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!