-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #4608 from rhuanjl:HostPromiseRejection Responding to #2530 This PR contains: 1. Internal CC machinery for HostPromiseRejectionTracker [ecmaspec 25.4.1.9](https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker) - this should enable any host to implement a handler for uncaught promise rejections e.g. the method defined here [WhatW spec 8.1.3.12](https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections) 2. A very simplistic implementation in ch (behind a command line flag) 3. Test case I'm expecting feedback/changes before this is merged but wanted to get other people's thoughts on it in this state. Please give me your thoughts/comments. Cross ref: [Edge uservoice request for this feature](https://wpdev.uservoice.com/forums/257854-microsoft-edge-developer/suggestions/16665397-detect-unhandled-promise-rejection?tracking_code=4f4e218df62afae7db37fb5be5f4ff1c) - note this PR will not put the feature in edge - it just creates the hooks the edge development team would have to track them through. **cc** @liminzhu @saschanaz @fatcerberus @MSLaguana **Notes:** **1. Not spec compliant for "await" EDIT: snip - re-read spec this comment was wrong what I've done in this PR is correct** **2. The ch implementation I've done is pretty bad,** it simply prints to the terminal whenever a notification is made, either handled or rejected - reasonable for testing that the interface is operational but certainly not what the WhatW spec would have a Host do. **3. Parameters passed to the callback function** - per spec HostPromiseRejectionTracker should be passed the Promise and rejected/handled. I've gone for: a) the promise b) the promise's result - I know this could be retrieved from the promise object but I've added it for implementer's convenience c) rejected/handled boolean - true for handled false for rejected - possibly should be an int or an enum of some kind
- Loading branch information
Showing
16 changed files
with
336 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,3 +62,5 @@ JsLessThan | |
JsLessThanOrEqual | ||
|
||
JsCreateEnhancedFunction | ||
|
||
JsSetHostPromiseRejectionTracker |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Executing test #1 - Reject promise with no reactions. | ||
Uncaught promise rejection | ||
Rejection from test 1 | ||
Executing test #2 - Reject promise with a catch reaction only. | ||
Executing test #3 - Reject promise with catch and then reactions. | ||
Executing test #4 - Reject promise then add a catch afterwards. | ||
Uncaught promise rejection | ||
Rejection from test 4 | ||
Promise rejection handled | ||
Rejection from test 4 | ||
Executing test #5 - Reject promise then add two catches afterwards. | ||
Uncaught promise rejection | ||
Rejection from test 5 | ||
Promise rejection handled | ||
Rejection from test 5 | ||
Executing test #6 - Async function that throws. | ||
Uncaught promise rejection | ||
Rejection from test 6 | ||
Executing test #7 - Async function that throws but is caught. | ||
Uncaught promise rejection | ||
Rejection from test 7 | ||
Promise rejection handled | ||
Rejection from test 7 | ||
Executing test #8 - Async function that awaits a function that throws. | ||
Uncaught promise rejection | ||
Rejection from test 8 | ||
Promise rejection handled | ||
Rejection from test 8 | ||
Executing test #9 - Reject a handled promise then handle one of the handles but not the other. | ||
Executing test #10 - Reject a handled promise and don't handle either path. | ||
Begin async results: | ||
Uncaught promise rejection | ||
Rejection from test 8 | ||
Uncaught promise rejection | ||
Rejection from test 9 | ||
Uncaught promise rejection | ||
Rejection from test 10 | ||
Uncaught promise rejection | ||
Rejection from test 10 | ||
Promise rejection handled | ||
Rejection from test 9 | ||
Uncaught promise rejection | ||
Rejection from test 9 |
Oops, something went wrong.