-
Notifications
You must be signed in to change notification settings - Fork 916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaughtable error seems to be caughtable when it occurs inside a Promise, is that an expected behavior? #341
Comments
it can cause this issue: #363 |
Can you post a simple example and specify what you think ought to happen and what actually happens? If this is a dup of #363, then it was fixed a few months back in quickjs-ng in quickjs-ng/quickjs@7ad9807. |
An uncaughtable is an error triggered by an interrupt handler: /* Example: using interrupt handler to limit the execution time. */
static int exec_timeout_check_handler(JSRuntime *rt, void *opaque)
{
if (timeout) return 1;
return 0;
}
/* ... */
JS_SetInterruptHandler(rt, exec_timeout_check_handler, opaque); When running non-async logic via Check the differences in the source code: JS_CallInternal js_async_function_resume I think we should change |
Does it work with this patch applied? diff --git a/quickjs.c b/quickjs.c
index a503eab..0a81a7f 100644
--- a/quickjs.c
+++ b/quickjs.c
@@ -18005,9 +18005,12 @@ static void js_async_function_resume(JSContext *ctx, JSAsyncFunctionData *s)
if (JS_IsException(func_ret)) {
JSValue error;
fail:
+ ret2 = JS_UNDEFINED;
error = JS_GetException(ctx);
- ret2 = JS_Call(ctx, s->resolving_funcs[1], JS_UNDEFINED,
- 1, &error);
+ if (!JS_IsUncatchableError(ctx, error)) {
+ ret2 = JS_Call(ctx, s->resolving_funcs[1], JS_UNDEFINED,
+ 1, &error);
+ }
JS_FreeValue(ctx, error);
js_async_function_terminate(ctx->rt, s);
JS_FreeValue(ctx, ret2); /* XXX: what to do if exception ? */ (Diff against quickjs-ng; you may have to massage it a little for this repo) |
I think it will work in some way, but I don't think that's a complete fix. As I will post my test here later. |
As my project already switched to quickjs-ng, I will continue this issue there quickjs-ng/quickjs#810 |
The uncaughtable error can be thrown by an interrupt handler.
Noticed that the
fail
logic ofjs_async_function_resume
function doesn't check if an exception is caughtable before sending it to thereject
function of the Promise.I wonder if it is an expected behavior.
https://github.com/bellard/quickjs/blob/6e2e68fd0896957f92eb6c242a2e048c1ef3cae0/quickjs.c#L19236-L19239
The text was updated successfully, but these errors were encountered: