We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Original issue I posted here bellard/quickjs#341
Test Code
#include <gtest/gtest.h> #include <quickjs.h> #define MAX_VAL 100 static int timeout_interrupt_handler(JSRuntime *rt, void *opaque) { int *time = (int *)opaque; if (*time == MAX_VAL) { std::cout << "Timeout" << std::endl; } if (*time <= MAX_VAL) { *time += 1; } return *time > MAX_VAL; } TEST(QuickJS, timeout_interrupt) { const char *code = "(async function() { \ const loop = async () => { \ await Promise.resolve(); \ while (true) {} \ }; \ while (true) { \ await loop().catch(() => {}); \ } \ })();"; JSRuntime *rt = JS_NewRuntime(); JSContext *ctx = JS_NewContext(rt); int time = 0; JS_SetInterruptHandler(rt, timeout_interrupt_handler, &time); JSValue ret = JS_Eval(ctx, code, strlen(code), "<input>", JS_EVAL_TYPE_GLOBAL); EXPECT_FALSE(JS_IsException(ret)); JS_FreeValue(ctx, ret); EXPECT_TRUE(JS_IsJobPending(rt)); int r = 0; while (JS_IsJobPending(rt)) { r = JS_ExecutePendingJob(rt, &ctx); } EXPECT_GT(time, MAX_VAL); EXPECT_FALSE(JS_IsJobPending(rt)); EXPECT_EQ(r, -1); EXPECT_TRUE(JS_HasException(ctx)); JS_FreeContext(ctx); JS_FreeRuntime(rt); }
Expected It should end when timeout occurs.
Actual It never ends.
The text was updated successfully, but these errors were encountered:
Fix uncatchable error inside a promise (quickjs-ng#810)
bf50cdb
d2fa383
0ec426d
5d27eb3
dd135d4
No branches or pull requests
Original issue I posted here bellard/quickjs#341
Test Code
Expected
It should end when timeout occurs.
Actual
It never ends.
The text was updated successfully, but these errors were encountered: