@@ -18002,20 +18002,32 @@ static int js_async_function_resolve_create(JSContext *ctx,
18002
18002
return 0;
18003
18003
}
18004
18004
18005
- static void js_async_function_resume(JSContext *ctx, JSAsyncFunctionData *s)
18005
+ static BOOL js_async_function_resume(JSContext *ctx, JSAsyncFunctionData *s)
18006
18006
{
18007
+ BOOL is_success = TRUE;
18007
18008
JSValue func_ret, ret2;
18008
18009
18009
18010
func_ret = async_func_resume(ctx, &s->func_state);
18010
18011
if (JS_IsException(func_ret)) {
18011
- JSValue error;
18012
18012
fail:
18013
- error = JS_GetException(ctx);
18014
- ret2 = JS_Call(ctx, s->resolving_funcs[1], JS_UNDEFINED,
18013
+ if (unlikely(JS_IsUncatchableError(ctx, ctx->rt->current_exception))) {
18014
+ is_success = FALSE;
18015
+ } else {
18016
+ JSValue error = JS_GetException(ctx);
18017
+ ret2 = JS_Call(ctx, s->resolving_funcs[1], JS_UNDEFINED,
18015
18018
1, &error);
18016
- JS_FreeValue(ctx, error);
18019
+ JS_FreeValue(ctx, error);
18020
+ resolved:
18021
+ if (unlikely(JS_IsException(ret2))) {
18022
+ if (JS_IsUncatchableError(ctx, ctx->rt->current_exception)) {
18023
+ is_success = FALSE;
18024
+ } else {
18025
+ abort(); /* BUG */
18026
+ }
18027
+ }
18028
+ JS_FreeValue(ctx, ret2);
18029
+ }
18017
18030
js_async_function_terminate(ctx->rt, s);
18018
- JS_FreeValue(ctx, ret2); /* XXX: what to do if exception ? */
18019
18031
} else {
18020
18032
JSValue value;
18021
18033
value = s->func_state.frame.cur_sp[-1];
@@ -18024,9 +18036,8 @@ static void js_async_function_resume(JSContext *ctx, JSAsyncFunctionData *s)
18024
18036
/* function returned */
18025
18037
ret2 = JS_Call(ctx, s->resolving_funcs[0], JS_UNDEFINED,
18026
18038
1, &value);
18027
- JS_FreeValue(ctx, ret2); /* XXX: what to do if exception ? */
18028
18039
JS_FreeValue(ctx, value);
18029
- js_async_function_terminate(ctx->rt, s) ;
18040
+ goto resolved ;
18030
18041
} else {
18031
18042
JSValue promise, resolving_funcs[2], resolving_funcs1[2];
18032
18043
int i, res;
@@ -18057,6 +18068,7 @@ static void js_async_function_resume(JSContext *ctx, JSAsyncFunctionData *s)
18057
18068
goto fail;
18058
18069
}
18059
18070
}
18071
+ return is_success;
18060
18072
}
18061
18073
18062
18074
static JSValue js_async_function_resolve_call(JSContext *ctx,
@@ -18081,7 +18093,9 @@ static JSValue js_async_function_resolve_call(JSContext *ctx,
18081
18093
/* return value of await */
18082
18094
s->func_state.frame.cur_sp[-1] = js_dup(arg);
18083
18095
}
18084
- js_async_function_resume(ctx, s);
18096
+ if (!js_async_function_resume(ctx, s)) {
18097
+ return JS_EXCEPTION;
18098
+ }
18085
18099
return JS_UNDEFINED;
18086
18100
}
18087
18101
@@ -18113,7 +18127,9 @@ static JSValue js_async_function_call(JSContext *ctx, JSValue func_obj,
18113
18127
}
18114
18128
s->is_active = TRUE;
18115
18129
18116
- js_async_function_resume(ctx, s);
18130
+ if (!js_async_function_resume(ctx, s)) {
18131
+ goto fail;
18132
+ }
18117
18133
18118
18134
js_async_function_free(ctx->rt, s);
18119
18135
@@ -48609,8 +48625,12 @@ static JSValue promise_reaction_job(JSContext *ctx, int argc,
48609
48625
res = JS_Call(ctx, handler, JS_UNDEFINED, 1, &arg);
48610
48626
}
48611
48627
is_reject = JS_IsException(res);
48612
- if (is_reject)
48628
+ if (is_reject) {
48629
+ if (unlikely(JS_IsUncatchableError(ctx, ctx->rt->current_exception))) {
48630
+ return JS_EXCEPTION;
48631
+ }
48613
48632
res = JS_GetException(ctx);
48633
+ }
48614
48634
func = argv[is_reject];
48615
48635
/* as an extension, we support undefined as value to avoid
48616
48636
creating a dummy promise in the 'await' implementation of async
0 commit comments