Commit e650b9e4 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[async] Gracefully handle exceptions in async_hooks.

When --async-stack-traces is on and there's an exception from within an
async_hook "after" handler, we will be faced with a settled promise. In
that case we cannot do anything, since the promise will not have any
reactions on it anymore, but we should also not crash of course.

Bug: chromium:896700, v8:7522
Change-Id: I6e3d212d0433da40740489ff7421c5a98cf9bff3
Reviewed-on: https://chromium-review.googlesource.com/c/1290550Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56801}
parent 19cec9b3
...@@ -614,9 +614,10 @@ bool IsBuiltinFunction(Isolate* isolate, HeapObject* object, ...@@ -614,9 +614,10 @@ bool IsBuiltinFunction(Isolate* isolate, HeapObject* object,
void CaptureAsyncStackTrace(Isolate* isolate, Handle<JSPromise> promise, void CaptureAsyncStackTrace(Isolate* isolate, Handle<JSPromise> promise,
FrameArrayBuilder* builder) { FrameArrayBuilder* builder) {
CHECK_EQ(Promise::kPending, promise->status());
while (!builder->full()) { while (!builder->full()) {
// Check that the {promise} is not settled.
if (promise->status() != Promise::kPending) return;
// Check that we have exactly one PromiseReaction on the {promise}. // Check that we have exactly one PromiseReaction on the {promise}.
if (!promise->reactions()->IsPromiseReaction()) return; if (!promise->reactions()->IsPromiseReaction()) return;
Handle<PromiseReaction> reaction( Handle<PromiseReaction> reaction(
......
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --async-stack-traces --expose-async-hooks
async_hooks.createHook({
after() { throw new Error(); }
}).enable();
Promise.resolve().then();
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