fix(promise): set [[PromiseIsHandled]] correctly#4983
Merged
jedel1043 merged 1 commit intoboa-dev:mainfrom Mar 10, 2026
Merged
Conversation
…iseThen
Step 12 of the PerformPromiseThen spec (§27.2.5.4.1) requires setting
promise.[[PromiseIsHandled]] to true regardless of the promise's current
state. The flag was only being set inside the Rejected branch, leaving it
false for pending promises with attached handlers. This caused RejectPromise
to fire spurious HostPromiseRejectionTracker("reject") events even when a
.catch() handler was already registered.
Signed-off-by: ashnaaseth2325-oss <ashnaaseth2325@gmail.com>
Test262 conformance changes
Tested main commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4983 +/- ##
===========================================
+ Coverage 47.24% 58.36% +11.12%
===========================================
Files 476 556 +80
Lines 46892 61154 +14262
===========================================
+ Hits 22154 35695 +13541
- Misses 24738 25459 +721 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes how
[[PromiseIsHandled]]is set inPromise::perform_promise_then.According to the ECMAScript spec, step 12 of PerformPromiseThen must run unconditionally.
Currently, Boa sets
handled = trueonly inside the Rejected branch, which means pending promises with a.catch()attached can still be reported as unhandled later.Example of the previous placement:
Because of this, promises that register a handler while still pending may incorrectly trigger the host rejection tracker.
Steps to Reproduce
Example JavaScript:
p.catch(() => {});
Expected behavior:
-The rejection is handled, so no unhandled-rejection tracking should occur.
Actual behavior before this fix:
-The host rejection tracker may fire because [[PromiseIsHandled]] was never set while the promise was pending.
Impact
Handled rejections can be reported as unhandled.
Hosts relying on
HostPromiseRejectionTrackermay emit incorrect warnings or test failures.This mostly affects the common case where
.catch()is attached before the promise settles.Fix
Move the assignment of
[[PromiseIsHandled]]so it runs after the match block, ensuring it applies regardless of the promise state.This aligns the implementation with ECMAScript §27.2.5.4.1 PerformPromiseThen step 12.
Result
-
[[PromiseIsHandled]]is now set correctly for pending, fulfilled, and rejected promises.-Handled rejections no longer trigger spurious unhandled-rejection tracking.
-Behavior now matches the ECMAScript specification.