Running async functions on Google Apps Script

别等时光非礼了梦想. 提交于 2021-02-04 05:18:51

问题


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)
}

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?

Update:

Created a issue at https://issuetracker.google.com/issues/153828715


回答1:


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.

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.

Reference:

  • Issue Tracker: Async with V8 is not implemented as async / concurrent; documentation could be improved
  • V8 Runtime Overview: Improved function detection


来源:https://stackoverflow.com/questions/61190809/running-async-functions-on-google-apps-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!