diff --git a/src/me/topchetoeu/jscript/lib/PromiseLib.java b/src/me/topchetoeu/jscript/lib/PromiseLib.java index 3df19c0..9766ee6 100644 --- a/src/me/topchetoeu/jscript/lib/PromiseLib.java +++ b/src/me/topchetoeu/jscript/lib/PromiseLib.java @@ -252,7 +252,7 @@ import me.topchetoeu.jscript.interop.Native; this.val = val; this.state = STATE_FULFILLED; - ctx.engine.pushMsg(false, ctx, new NativeFunction((_ctx, _thisArg, _args) -> { + ctx.engine.pushMsg(true, ctx, new NativeFunction((_ctx, _thisArg, _args) -> { for (var handle : handles) { handle.fulfilled.call(handle.ctx, null, val); } @@ -287,11 +287,12 @@ import me.topchetoeu.jscript.interop.Native; this.val = val; this.state = STATE_REJECTED; - ctx.engine.pushMsg(false, ctx, new NativeFunction((_ctx, _thisArg, _args) -> { + ctx.engine.pushMsg(true, ctx, new NativeFunction((_ctx, _thisArg, _args) -> { for (var handle : handles) handle.rejected.call(handle.ctx, null, val); - if (!handled) { + if (handles.size() == 0) { Values.printError(new EngineException(val).setCtx(ctx.environment(), ctx.engine), "(in promise)"); } + handles = null; return null; }), null); }