[quickjs-devel] Unable to await promise

  • From: Yifeng Wang <doodlewind@xxxxxxxxx>
  • To: quickjs-devel@xxxxxxxxxxxxx
  • Date: Wed, 26 Feb 2020 21:49:36 +0800

Hi,

Promise is supposed to be able to use with await, while in the 2020-01-05
and 2020-01-19 build, following code does not work:

```
function resolveAfter2Seconds (x) {
  return new Promise(resolve => {
    setTimeout(() => {
      resolve(x);
    }, 2000);
  });
}

async function f1 () {
  var x = await resolveAfter2Seconds(10);
  console.log(x); // 10
}

f1();
```

Run the script, node will wait until the output, while qjs returns
immediately. The code is just the demo from MDN:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await

I guess this is a regression, since I've made such usage with the 2019-10
release before.

Regards
Yifeng Wang

Other related posts: