From d6d40e5f2cfa3bd07a811659d7d707127a482abb Mon Sep 17 00:00:00 2001 From: johnche Date: Thu, 18 Apr 2024 19:56:35 +0800 Subject: [PATCH] =?UTF-8?q?[unity]=E6=9C=80=E6=96=B0=E7=89=88qjs=E7=9A=84?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=EF=BC=8C=E8=AF=A5backend=E5=88=86=E6=94=AF?= =?UTF-8?q?=EF=BC=9Ahttps://github.com/puerts/backend-quickjs/tree/update?= =?UTF-8?q?=5Fquickjs=5F20240417?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- unity/native_src/Src/BackendEnv.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/unity/native_src/Src/BackendEnv.cpp b/unity/native_src/Src/BackendEnv.cpp index 3f9c014808..ce361d36ca 100644 --- a/unity/native_src/Src/BackendEnv.cpp +++ b/unity/native_src/Src/BackendEnv.cpp @@ -713,6 +713,18 @@ JSValue esmodule::ExecuteModule(JSContext *ctx, JSValueConst this_val, int argc, if (JS_IsException(EvalRet)) { return EvalRet; } +#if defined(JS_EVAL_FLAG_ASYNC) + if (!JS_IsUndefined(EvalRet)) + { + JSPromiseStateEnum state = JS_PromiseState(ctx, EvalRet); + if (state == JS_PROMISE_REJECTED) + { + auto ret = JS_Throw(ctx, JS_PromiseResult(ctx, EvalRet)); + JS_FreeValue(ctx, EvalRet); + return ret; + } + } +#endif JS_FreeValue(ctx, EvalRet); auto Namespace = JS_GET_MODULE_NS(ctx, EntryModule); if (JS_IsUndefined(Namespace) || JS_IsNull(Namespace))