Commit 697c575af40 for nodejs
commit 697c575af40c625fda9220ca8dc575a792b93621
Author: Michaël Zasso <targos@protonmail.com>
Date: Fri Oct 30 11:27:01 2026 +0100
src,test: use non-deprecated `v8::FunctionCallbackInfo::DataV2` API
Co-Authored-By: Joyee Cheung <joyeec9h3@gmail.com>
Signed-Off-By: Michaël Zasso <targos@protonmail.com>
Signed-off-by: Chengzhong Wu <cwu631@bloomberg.net>
PR-URL: https://github.com/nodejs/node/pull/67070
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
diff --git a/doc/api/addons.md b/doc/api/addons.md
index 80d23a4cf48..315bcda1642 100644
--- a/doc/api/addons.md
+++ b/doc/api/addons.md
@@ -214,7 +214,7 @@ class AddonData {
static void Method(const v8::FunctionCallbackInfo<v8::Value>& info) {
// Retrieve the per-addon-instance data.
AddonData* data =
- reinterpret_cast<AddonData*>(info.Data().As<External>()->Value());
+ reinterpret_cast<AddonData*>(info.DataV2().As<External>()->Value());
data->call_count++;
info.GetReturnValue().Set((double)data->call_count);
}
@@ -982,7 +982,7 @@ void MyObject::New(const FunctionCallbackInfo<Value>& args) {
const int argc = 1;
Local<Value> argv[argc] = { args[0] };
Local<Function> cons =
- args.Data().As<Object>()->GetInternalField(0)
+ args.DataV2().As<Value>().As<Object>()->GetInternalField(0)
.As<Value>().As<Function>();
Local<Object> result =
cons->NewInstance(context, argc, argv).ToLocalChecked();
diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc
index ba1ab6f1851..863b0f9e3ae 100644
--- a/src/js_native_api_v8.cc
+++ b/src/js_native_api_v8.cc
@@ -491,7 +491,9 @@ class FunctionCallbackWrapper {
explicit FunctionCallbackWrapper(
const v8::FunctionCallbackInfo<v8::Value>& cbinfo)
: cbinfo_(cbinfo),
- bundle_(CallbackBundle::FromCallbackData(cbinfo.Data())) {}
+ bundle_(
+ CallbackBundle::FromCallbackData(cbinfo.DataV2().As<v8::Value>())) {
+ }
void InvokeCallback() {
napi_callback_info cbinfo_wrapper =
diff --git a/src/module_wrap.cc b/src/module_wrap.cc
index 444d3133753..be3e6f668c0 100644
--- a/src/module_wrap.cc
+++ b/src/module_wrap.cc
@@ -1259,7 +1259,7 @@ static void ImportMetaResolveLazyGetter(
// This should be createImportMetaResolve(). The loader argument is already
// bound at initialization time.
- Local<Value> args[] = {info.Data()};
+ Local<Value> args[] = {info.DataV2().As<Value>()};
Local<Value> ret;
if (!initializer
->Call(context, Undefined(realm->isolate()), arraysize(args), args)
@@ -1290,7 +1290,7 @@ static void PathHelpersLazyGetter(Local<v8::Name> name,
}
Environment* env = Environment::GetCurrent(context);
- node::Utf8Value url(isolate, info.Data());
+ node::Utf8Value url(isolate, info.DataV2().As<Value>());
auto file_url = ada::parse(url.ToStringView());
CHECK(file_url);
auto file_path = url::FileURLToPath(env, *file_url);
diff --git a/src/node_ffi.cc b/src/node_ffi.cc
index b8127587d4e..9b0703b84e9 100644
--- a/src/node_ffi.cc
+++ b/src/node_ffi.cc
@@ -664,7 +664,7 @@ void DynamicLibrary::Close(const FunctionCallbackInfo<Value>& args) {
void DynamicLibrary::InvokeFunction(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
- FFIFunctionInfo* info = Unwrap<FFIFunctionInfo>(args.Data());
+ FFIFunctionInfo* info = Unwrap<FFIFunctionInfo>(args.DataV2().As<Value>());
CHECK_NOT_NULL(info);
FFIFunction* fn = info->fn.get();
@@ -736,7 +736,7 @@ void DynamicLibrary::InvokeFunction(const FunctionCallbackInfo<Value>& args) {
void DynamicLibrary::InvokeFunctionSB(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
- FFIFunctionInfo* info = Unwrap<FFIFunctionInfo>(args.Data());
+ FFIFunctionInfo* info = Unwrap<FFIFunctionInfo>(args.DataV2().As<Value>());
CHECK_NOT_NULL(info);
FFIFunction* fn = info->fn.get();
diff --git a/src/node_locks.cc b/src/node_locks.cc
index 4fca3a7df94..c58efbf5561 100644
--- a/src/node_locks.cc
+++ b/src/node_locks.cc
@@ -130,7 +130,7 @@ static void OnLockCallbackFulfilled(const FunctionCallbackInfo<Value>& info) {
Environment* env = Environment::GetCurrent(info);
BaseObjectPtr<LockHolder> lock_holder{
- BaseObject::FromJSObject<LockHolder>(info.Data())};
+ BaseObject::FromJSObject<LockHolder>(info.DataV2().As<Value>())};
std::shared_ptr<Lock> lock = lock_holder->lock();
// Release the lock and continue processing the queue.
@@ -144,7 +144,7 @@ static void OnLockCallbackRejected(const FunctionCallbackInfo<Value>& info) {
Environment* env = Environment::GetCurrent(info);
BaseObjectPtr<LockHolder> lock_holder{
- BaseObject::FromJSObject<LockHolder>(info.Data())};
+ BaseObject::FromJSObject<LockHolder>(info.DataV2().As<Value>())};
std::shared_ptr<Lock> lock = lock_holder->lock();
LockManager::GetCurrent()->ReleaseLockAndProcessQueue(
@@ -154,13 +154,13 @@ static void OnLockCallbackRejected(const FunctionCallbackInfo<Value>& info) {
// Called when the promise returned from the user's callback resolves
static void OnIfAvailableFulfill(const FunctionCallbackInfo<Value>& info) {
HandleScope handle_scope(info.GetIsolate());
- USE(info.Data().As<Promise::Resolver>()->Resolve(
+ USE(info.DataV2().As<Value>().As<Promise::Resolver>()->Resolve(
info.GetIsolate()->GetCurrentContext(), info[0]));
}
// Called when the promise returned from the user's callback rejects
static void OnIfAvailableReject(const FunctionCallbackInfo<Value>& info) {
- USE(info.Data().As<Promise::Resolver>()->Reject(
+ USE(info.DataV2().As<Value>().As<Promise::Resolver>()->Reject(
info.GetIsolate()->GetCurrentContext(), info[0]));
}
diff --git a/src/node_util.cc b/src/node_util.cc
index e19ba77e264..a8f4188b4db 100644
--- a/src/node_util.cc
+++ b/src/node_util.cc
@@ -374,7 +374,7 @@ static void DefineLazyPropertiesGetter(
}
Realm* realm = Realm::GetCurrent(context);
- Local<Value> arg = info.Data();
+ Local<Value> arg = info.DataV2().As<Value>();
Local<Value> require_result;
if (!realm->builtin_module_require()
->Call(context, Null(isolate), 1, &arg)
diff --git a/src/node_wasm_web_api.cc b/src/node_wasm_web_api.cc
index a49cab7fb62..d977793eb13 100644
--- a/src/node_wasm_web_api.cc
+++ b/src/node_wasm_web_api.cc
@@ -157,7 +157,7 @@ void StartStreamingCompilation(const FunctionCallbackInfo<Value>& info) {
// Create the wrapper object.
std::shared_ptr<WasmStreaming> streaming =
- WasmStreaming::Unpack(info.GetIsolate(), info.Data());
+ WasmStreaming::Unpack(info.GetIsolate(), info.DataV2());
Environment* env = Environment::GetCurrent(info);
Local<Object> obj;
if (!WasmStreamingObject::Create(env, streaming).ToLocal(&obj)) {
diff --git a/test/addons/worker-addon-exit/binding.cc b/test/addons/worker-addon-exit/binding.cc
index 312534fa4c7..33ab053c234 100644
--- a/test/addons/worker-addon-exit/binding.cc
+++ b/test/addons/worker-addon-exit/binding.cc
@@ -72,7 +72,8 @@ void MyObject::New(const FunctionCallbackInfo<Value>& args) {
// Invoked as plain function `MyObject(...)`, turn into construct call.
const int argc = 1;
Local<Value> argv[argc] = {args[0]};
- Local<Function> cons = args.Data()
+ Local<Function> cons = args.DataV2()
+ .As<Value>()
.As<Object>()
->GetInternalField(0)
.As<Value>()
diff --git a/test/cctest/test_environment.cc b/test/cctest/test_environment.cc
index 1f6d3012e25..cec49dac916 100644
--- a/test/cctest/test_environment.cc
+++ b/test/cctest/test_environment.cc
@@ -694,8 +694,8 @@ TEST_F(EnvironmentTest, RunAndClearNativeImmediatesSkipsEmptyScope) {
v8::Function::New(
context,
[](const v8::FunctionCallbackInfo<v8::Value>& info) {
- IntVec* callback_calls =
- static_cast<IntVec*>(info.Data().As<v8::External>()->Value(
+ IntVec* callback_calls = static_cast<IntVec*>(
+ info.DataV2().As<v8::Value>().As<v8::External>()->Value(
v8::kExternalPointerTypeTagDefault));
callback_calls->push_back(info[0].As<v8::Int32>()->Value());
},
@@ -1081,8 +1081,8 @@ TEST_F(EnvironmentTest, NestedMicrotaskQueue) {
v8::Function::New(
context,
[](const v8::FunctionCallbackInfo<v8::Value>& info) {
- IntVec* callback_calls =
- static_cast<IntVec*>(info.Data().As<v8::External>()->Value(
+ IntVec* callback_calls = static_cast<IntVec*>(
+ info.DataV2().As<v8::Value>().As<v8::External>()->Value(
v8::kExternalPointerTypeTagDefault));
callback_calls->push_back(info[0].As<v8::Int32>()->Value());
},