Skip to content

Commit 51b4dda

Browse files
committed
Mark rejected promises with no reactions as handled
1 parent 1c395ba commit 51b4dda

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

quickjs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50278,6 +50278,10 @@ static void fulfill_or_reject_promise(JSContext *ctx, JSValueConst promise,
5027850278
}
5027950279
}
5028050280

50281+
// If the promise has no reactions, mark it as handled.
50282+
if (list_empty(&s->promise_reactions[is_reject]))
50283+
s->is_handled = true;
50284+
5028150285
list_for_each_safe(el, el1, &s->promise_reactions[is_reject]) {
5028250286
rd = list_entry(el, JSPromiseReactionData, link);
5028350287
args[0] = rd->resolving_funcs[0];

tests/bug39/3.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*---
2+
flags: [qjs:track-promise-rejections]
3+
---*/
4+
5+
const promise = Promise.reject('reject')
6+
const error = await Promise.resolve().then(() => promise).catch(e => e)
7+
print('Got this error:', error)

tests/bug39/4.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/*---
2+
flags: [qjs:track-promise-rejections]
3+
---*/
4+
5+
const promise = Promise.reject('reject')
6+
print(promise)

0 commit comments

Comments
 (0)