Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
880 views
in Technique[技术] by (71.8m points)

asynchronous - Running async functions on Google Apps Script

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...