本文介绍了在Google Apps脚本上运行异步功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在新的V8 Google Apps脚本运行时上运行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脚本上运行异步功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 22:45