Commit 61a6b6f2 authored by littledan's avatar littledan Committed by Commit bot

async/await: Don't trigger uncaught rejection handlers on throwaway Promises

This patch implements a bug fix to the async/await specification described
at https://github.com/tc39/ecma262/pull/692#issuecomment-247488411
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}
parent a0ba18e9
......@@ -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");
// -------------------------------------------------------------------
......@@ -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);
}
......
......@@ -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",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment