sebastienros / jint

Javascript Interpreter for .NET
BSD 2-Clause "Simplified" License
4.11k stars 563 forks source link

System.InvalidOperationException: 'UnwrapIfPromise' called before Promise was settled #1814

Closed scgm0 closed 7 months ago

scgm0 commented 7 months ago
Engine engine = new();
engine.SetValue("setTimeout", (Action action, int delay) => {
    Task.Delay(delay).ContinueWith(_ => action());
});

var result = engine.Evaluate(@"
const waitFor = delay => new Promise(resolve => setTimeout(resolve, delay));
async function main() {
    await waitFor(500);
    return 'hello';
}
main;");
Console.WriteLine(result.Call());
hiperz commented 7 months ago

I got the same problem.