facebook / hermes

A JavaScript engine optimized for running React Native.

Home Page:https://hermesengine.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for Async/Await and Promise with JSI API

verenkoska opened this issue · comments

Description

The following code only prints the string when using the Hermes' executable, but not with the JSI API:

async function test() {
 await 1;
 print("Hello World!");
}
test();

Same happens with promises:

promise = new Promise(function(resolve) { resolve(); });
promise.then(function() { print("Hello World!"); });

Do you know how can I get the same behaviour in both situations?
I already tried multiple runtime configurations when creating the JSI runtime, but did not manage to find a solution.

Thank you for the support!

Is this a custom integration of Hermes, outside of RN?

Promises and async require an event loop and one of:

  • Preferably, the micro-task queue has to be enabled and drained in every iteration of the event loop
  • Or an enqueuing function has to be stored in the global property setImmediate().

Thank you for the response!
Yes, it's custom.
Are there plans to integrate such a behaviour when using the JSI Api?

I don't understand what you mean. This behavior is correct and by design. It has nothing to do with JSI.