.Net7 NativeAOT, used [async/await] return Undefined
sudongg opened this issue · comments
Version used
main branch 3.0 beta
Describe the bug
After .Net7 NativeAOT is publish, use await to return Undefined
To Reproduce
Create a new console application
Main() Add oode:
try
{
test3();
}
catch
{
}
Console.ReadLine();
Add oode:
static void test3()
{
var engine = new Engine();
var d = new Func<Task<bool>>(async () =>
{
await Task.Delay(1000);
return true;
});
engine.SetValue("WriteLine", new Action<Jint.Native.JsValue> ((line) => { Console.WriteLine(line); }));
engine.SetValue("Test", d);
engine.Execute(@"
async function test(){
WriteLine('start');
WriteLine(await Test());
}
test();
");
}
Run, console output:
start
undefined
Expected behavior
Run, console output:
start
true
@sudongg does this work without AOT publish, like as normal console app?
Async interop is probably something that I'm not willing to spend energy on. Please create a PR for fixes with test cases attached and then we should be golden.
@sudongg does this work without AOT publish, like as normal console app?
yes, it is effective when there is no aot.
Now I don't use await return value directly, but get it after await, which temporarily solves the problem. I don't understand why. Hope this issue can be resolved soon.
This is something that we need your help with. There's no resources to investigate and fix such problems.