@@ -17998,20 +17998,30 @@ static int js_async_function_resolve_create(JSContext *ctx,
17998
17998
return 0;
17999
17999
}
18000
18000
18001
- static void js_async_function_resume(JSContext *ctx, JSAsyncFunctionData *s)
18001
+ static BOOL js_async_function_resume(JSContext *ctx, JSAsyncFunctionData *s)
18002
18002
{
18003
+ BOOL is_success = TRUE;
18003
18004
JSValue func_ret, ret2;
18004
18005
18005
18006
func_ret = async_func_resume(ctx, &s->func_state);
18006
18007
if (JS_IsException(func_ret)) {
18007
18008
JSValue error;
18008
18009
fail:
18009
18010
error = JS_GetException(ctx);
18010
- ret2 = JS_Call(ctx, s->resolving_funcs[1], JS_UNDEFINED,
18011
+ if (unlikely(JS_IsUncatchableError(ctx, error))) {
18012
+ JS_Throw(ctx, error);
18013
+ is_success = FALSE;
18014
+ } else {
18015
+ ret2 = JS_Call(ctx, s->resolving_funcs[1], JS_UNDEFINED,
18011
18016
1, &error);
18012
- JS_FreeValue(ctx, error);
18017
+ if (unlikely(JS_IsException(ret2))) {
18018
+ /* should only be uncatchable error */
18019
+ is_success = FALSE;
18020
+ }
18021
+ JS_FreeValue(ctx, error);
18022
+ JS_FreeValue(ctx, ret2);
18023
+ }
18013
18024
js_async_function_terminate(ctx->rt, s);
18014
- JS_FreeValue(ctx, ret2); /* XXX: what to do if exception ? */
18015
18025
} else {
18016
18026
JSValue value;
18017
18027
value = s->func_state.frame.cur_sp[-1];
@@ -18020,7 +18030,11 @@ static void js_async_function_resume(JSContext *ctx, JSAsyncFunctionData *s)
18020
18030
/* function returned */
18021
18031
ret2 = JS_Call(ctx, s->resolving_funcs[0], JS_UNDEFINED,
18022
18032
1, &value);
18023
- JS_FreeValue(ctx, ret2); /* XXX: what to do if exception ? */
18033
+ if (unlikely(JS_IsException(ret2))) {
18034
+ /* should only be uncatchable error */
18035
+ is_success = FALSE;
18036
+ }
18037
+ JS_FreeValue(ctx, ret2);
18024
18038
JS_FreeValue(ctx, value);
18025
18039
js_async_function_terminate(ctx->rt, s);
18026
18040
} else {
@@ -18053,6 +18067,7 @@ static void js_async_function_resume(JSContext *ctx, JSAsyncFunctionData *s)
18053
18067
goto fail;
18054
18068
}
18055
18069
}
18070
+ return is_success;
18056
18071
}
18057
18072
18058
18073
static JSValue js_async_function_resolve_call(JSContext *ctx,
@@ -18077,7 +18092,9 @@ static JSValue js_async_function_resolve_call(JSContext *ctx,
18077
18092
/* return value of await */
18078
18093
s->func_state.frame.cur_sp[-1] = js_dup(arg);
18079
18094
}
18080
- js_async_function_resume(ctx, s);
18095
+ if (!js_async_function_resume(ctx, s)) {
18096
+ return JS_EXCEPTION;
18097
+ }
18081
18098
return JS_UNDEFINED;
18082
18099
}
18083
18100
@@ -18109,7 +18126,9 @@ static JSValue js_async_function_call(JSContext *ctx, JSValue func_obj,
18109
18126
}
18110
18127
s->is_active = TRUE;
18111
18128
18112
- js_async_function_resume(ctx, s);
18129
+ if (!js_async_function_resume(ctx, s)) {
18130
+ goto fail;
18131
+ }
18113
18132
18114
18133
js_async_function_free(ctx->rt, s);
18115
18134
@@ -48605,8 +48624,13 @@ static JSValue promise_reaction_job(JSContext *ctx, int argc,
48605
48624
res = JS_Call(ctx, handler, JS_UNDEFINED, 1, &arg);
48606
48625
}
48607
48626
is_reject = JS_IsException(res);
48608
- if (is_reject)
48627
+ if (is_reject) {
48609
48628
res = JS_GetException(ctx);
48629
+ if (unlikely(JS_IsUncatchableError(ctx, res))) {
48630
+ JS_Throw(ctx, res);
48631
+ return JS_EXCEPTION;
48632
+ }
48633
+ }
48610
48634
func = argv[is_reject];
48611
48635
/* as an extension, we support undefined as value to avoid
48612
48636
creating a dummy promise in the 'await' implementation of async
0 commit comments