@@ -1260,6 +1260,8 @@ static JSValue js_promise_resolve(JSContext *ctx, JSValueConst this_val,
12601260 int argc, JSValueConst *argv, int magic);
12611261static JSValue js_promise_then(JSContext *ctx, JSValueConst this_val,
12621262 int argc, JSValueConst *argv);
1263+ static JSValue js_promise_resolve_thenable_job(JSContext *ctx,
1264+ int argc, JSValueConst *argv);
12631265static bool js_string_eq(JSString *p1, JSString *p2);
12641266static int js_string_compare(JSString *p1, JSString *p2);
12651267static int JS_SetPropertyValue(JSContext *ctx, JSValueConst this_obj,
@@ -50223,7 +50225,7 @@ static JSValue promise_rejection_tracker_job(JSContext *ctx, int argc,
5022350225 JSValueConst promise;
5022450226 struct list_head *el, *el1;
5022550227 JSJobEntry *job;
50226- bool has_other_jobs ;
50228+ bool has_other_promise_jobs ;
5022750229
5022850230 assert(argc == 1);
5022950231
@@ -50239,15 +50241,15 @@ static JSValue promise_rejection_tracker_job(JSContext *ctx, int argc,
5023950241 // Push the rejection tracker jobs to the end of the queue if there are other jobs.
5024050242 // This allows us to handle rejections that get added later and thus would handle the
5024150243 // rejection _after_ we check for it.
50242- has_other_jobs = false;
50244+ has_other_promise_jobs = false;
5024350245 list_for_each_safe(el, el1, &rt->job_list) {
5024450246 job = list_entry(el, JSJobEntry, link);
50245- if (job->job_func != promise_rejection_tracker_job ) {
50246- has_other_jobs = true;
50247+ if (job->job_func == promise_reaction_job || job->job_func == js_promise_resolve_thenable_job ) {
50248+ has_other_promise_jobs = true;
5024750249 break;
5024850250 }
5024950251 }
50250- if (has_other_jobs ) {
50252+ if (has_other_promise_jobs ) {
5025150253 JS_EnqueueJob(ctx, promise_rejection_tracker_job, 1, &promise);
5025250254 return JS_UNDEFINED;
5025350255 }
0 commit comments