Skip to content

Commit

Permalink
async/await: Don't trigger uncaught rejection handlers on throwaway P…
Browse files Browse the repository at this point in the history
…romises

This patch implements a bug fix to the async/await specification described
at tc39/ecma262#692 (comment)
Namely, the intermediate values of Promises may be rejected, and they do
not have .then called on them anymore (now that the memory leak is fixed),
but they do not correspond do unhandled rejections. This change has been
tested manually with integration with Blink; once it is checked in and
rolled, then further tests can be added on the Blink side for the uncaught
rejection handler and async/await.

BUG=v8:4483

Review-Url: https://codereview.chromium.org/2338273007
Cr-Commit-Position: refs/heads/master@{#39480}
  • Loading branch information
littledan authored and Commit bot committed Sep 16, 2016
1 parent a0ba18e commit 61a6b6f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/js/harmony-async-await.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ utils.Import(function(from) {
var promiseAwaitHandlerSymbol = utils.ImportNow("promise_await_handler_symbol");
var promiseHandledHintSymbol =
utils.ImportNow("promise_handled_hint_symbol");
var promiseHasHandlerSymbol =
utils.ImportNow("promise_has_handler_symbol");

// -------------------------------------------------------------------

Expand Down Expand Up @@ -89,6 +91,11 @@ function AsyncFunctionAwait(generator, awaited, mark) {

// Just forwarding the exception, so no debugEvent for throwawayCapability
var throwawayCapability = NewPromiseCapability(GlobalPromise, false);

// The Promise will be thrown away and not handled, but it shouldn't trigger
// unhandled reject events as its work is done
SET_PRIVATE(throwawayCapability.promise, promiseHasHandlerSymbol, true);

return PerformPromiseThen(promise, onFulfilled, onRejected,
throwawayCapability);
}
Expand Down
1 change: 1 addition & 0 deletions src/js/prologue.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ function PostNatives(utils) {
"promise_state_symbol",
"promise_await_handler_symbol",
"promise_handled_hint_symbol",
"promise_has_handler_symbol",
"object_freeze",
"object_is_frozen",
"object_is_sealed",
Expand Down

0 comments on commit 61a6b6f

Please sign in to comment.