Commit 1de7e249 authored by Maya Lekova's avatar Maya Lekova Committed by V8 LUCI CQ

[d8] Handle exceptions on async_hooks.createHook

Before we assumed that no exception can be thrown when specifying a
function to be used as an async hook, but that's not the case when e.g.
the object passed to createHook is a proxy trapping on property access
and the trap throws an exception.

Bug: chromium:1337629
Change-Id: I7bd7893cd274afb6e642ed18aacb9e203f7fdd96
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3714233
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81258}
parent 643d69f7
......@@ -134,12 +134,12 @@ Local<Object> AsyncHooks::CreateHook(
Local<Object> fn_obj = args[0].As<Object>();
#define SET_HOOK_FN(name) \
Local<Value> name##_v = \
fn_obj->Get(currentContext, String::NewFromUtf8Literal(isolate, #name)) \
.ToLocalChecked(); \
if (name##_v->IsFunction()) { \
wrap->set_##name##_function(name##_v.As<Function>()); \
#define SET_HOOK_FN(name) \
MaybeLocal<Value> name##_maybe_func = \
fn_obj->Get(currentContext, String::NewFromUtf8Literal(isolate, #name)); \
Local<Value> name##_func; \
if (name##_maybe_func.ToLocal(&name##_func) && name##_func->IsFunction()) { \
wrap->set_##name##_function(name##_func.As<Function>()); \
}
SET_HOOK_FN(init);
......
// Copyright 2022 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.
const failing_proxy = new Proxy({}, new Proxy({}, {
get() {
throw "No trap should fire";
}
}));
assertThrows(() => async_hooks.createHook(failing_proxy));
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