@@ -1260,6 +1260,8 @@ static JSValue js_promise_resolve(JSContext *ctx, JSValueConst this_val,
1260
1260
int argc, JSValueConst *argv, int magic);
1261
1261
static JSValue js_promise_then(JSContext *ctx, JSValueConst this_val,
1262
1262
int argc, JSValueConst *argv);
1263
+ static JSValue js_promise_resolve_thenable_job(JSContext *ctx,
1264
+ int argc, JSValueConst *argv);
1263
1265
static bool js_string_eq(JSString *p1, JSString *p2);
1264
1266
static int js_string_compare(JSString *p1, JSString *p2);
1265
1267
static int JS_SetPropertyValue(JSContext *ctx, JSValueConst this_obj,
@@ -50223,7 +50225,7 @@ static JSValue promise_rejection_tracker_job(JSContext *ctx, int argc,
50223
50225
JSValueConst promise;
50224
50226
struct list_head *el, *el1;
50225
50227
JSJobEntry *job;
50226
- bool has_other_jobs ;
50228
+ bool has_other_promise_jobs ;
50227
50229
50228
50230
assert(argc == 1);
50229
50231
@@ -50239,15 +50241,15 @@ static JSValue promise_rejection_tracker_job(JSContext *ctx, int argc,
50239
50241
// Push the rejection tracker jobs to the end of the queue if there are other jobs.
50240
50242
// This allows us to handle rejections that get added later and thus would handle the
50241
50243
// rejection _after_ we check for it.
50242
- has_other_jobs = false;
50244
+ has_other_promise_jobs = false;
50243
50245
list_for_each_safe(el, el1, &rt->job_list) {
50244
50246
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;
50247
50249
break;
50248
50250
}
50249
50251
}
50250
- if (has_other_jobs ) {
50252
+ if (has_other_promise_jobs ) {
50251
50253
JS_EnqueueJob(ctx, promise_rejection_tracker_job, 1, &promise);
50252
50254
return JS_UNDEFINED;
50253
50255
}
0 commit comments