chore: bump nan to 2.23.0 (#48591)

* chore: bump nan to 2.23.0

* Fix C++ flags passed to C compiler in NAN spec runner

Passing C++-specific flags to the C compiler caused failures building native test modules.

NAN uprgaded the version of node-gyp it uses, triggering a new codepath with the C compiler that didn't occur before. In that new branch, the C++ flags present in the CFLAGS environment variable we were passing in caused the C compiler to error out:

```
error: invalid argument '-std=c++20' not allowed with 'C'
```

The fix is to only pass C++-specific flags to the C++ compiler, and not the C compiler. This is done by separating out the CFLAGS and CXXFLAGS environment variables in our nan-spec-runner.js script.

I'm curious to know more about why each of these flags are necessary, but for now this change restores the previous behavior where native test modules could be built successfully.

* test: use v8 version check instead of node version check (patch)

* Re-enable `methodswithdata-test`
This commit is contained in:
Calvin
2025-10-23 12:58:40 -06:00
committed by GitHub
parent 717eb0dca5
commit 418b8235bc
14 changed files with 90 additions and 566 deletions

2
DEPS
View File

@@ -6,7 +6,7 @@ vars = {
'node_version':
'v22.20.0',
'nan_version':
'e14bdcd1f72d62bca1d541b66da43130384ec213',
'675cefebca42410733da8a454c8d9391fcebfbc2',
'squirrel.mac_version':
'0e5d146ba13101a1302d59ea6e6e0b3cace4ae38',
'reactiveobjc_version':

View File

@@ -1,10 +1,4 @@
use_new_constructor_for_scriptorigin_when_17_x.patch
fix_define_nan_copyablepersistenttraits_for_v8_12_5.patch
remove_deprecated_v8_isolate_idlenotificationdeadline.patch
remove_several_apis_deprecated_in_version_12_6.patch
apply_allcan_read_write.patch
fix_support_new_variant_of_namedpropertyhandlerconfiguration_and.patch
fix_correct_usages_of_v8_returnvalue_void_set_nonempty_for_new.patch
chore_remove_deprecated_functioncallbackinfo_holder.patch
fix_replace_deprecated_get_setprototype.patch
fix_replace_usage_of_removed_writeutf8_with_writeutf8v2.patch
test_use_v8_version_check_instead_of_node_version_check.patch

View File

@@ -1,141 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Keeley Hammond <khammond@slack-corp.com>
Date: Thu, 20 Jun 2024 14:42:08 -0700
Subject: Check for NODE_21_0_MODULE_VERSION
Refs https://chromium-review.googlesource.com/c/v8/v8/+/5006387
Should be upstreamed.
Module version checks are made against 119 since that is the current assigned version
for Electron 28 in https://github.com/nodejs/node/blob/main/doc/abi_version_registry.json.
The version should be updateed to the one assinged for Electron 29 when it is available.
Steps for upstreaming this patch:
- Get a new module version assigned for Electron 29 in nodejs/node
- Update NODE_21_0_MODULE_VERSION to the new version number
- Upstream patch to nodejs/nan before Electron 29 is branched
diff --git a/nan.h b/nan.h
index 9a9112afe0cc94ce58ed3cce9763ace7c160a932..f4865a77e60d5105ed2426037984ddcbfa58bbca 100644
--- a/nan.h
+++ b/nan.h
@@ -47,6 +47,7 @@
#define NODE_18_0_MODULE_VERSION 108
#define NODE_19_0_MODULE_VERSION 111
#define NODE_20_0_MODULE_VERSION 115
+#define NODE_21_0_MODULE_VERSION 119
#ifdef _MSC_VER
# define NAN_HAS_CPLUSPLUS_11 (_MSC_VER >= 1800)
@@ -2525,7 +2526,9 @@ NAN_DEPRECATED inline void SetAccessor(
, GetterCallback getter
, SetterCallback setter
, v8::Local<v8::Value> data
+#if (NODE_MODULE_VERSION < NODE_21_0_MODULE_VERSION)
, v8::AccessControl settings
+#endif
, v8::PropertyAttribute attribute
, imp::Sig signature) {
HandleScope scope;
@@ -2553,17 +2556,28 @@ NAN_DEPRECATED inline void SetAccessor(
obj->SetInternalField(imp::kDataIndex, data);
}
+#if (NODE_MODULE_VERSION >= NODE_21_0_MODULE_VERSION)
+ tpl->SetNativeDataProperty(
+ name
+ , getter_
+ , setter_
+ , obj
+ , attribute);
+#else
tpl->SetAccessor(
name
, getter_
, setter_
, obj
+#if (NODE_MODULE_VERSION < NODE_21_0_MODULE_VERSION)
, settings
+#endif
, attribute
#if (NODE_MODULE_VERSION < NODE_16_0_MODULE_VERSION)
, signature
#endif
);
+#endif
}
inline void SetAccessor(
@@ -2572,7 +2586,9 @@ inline void SetAccessor(
, GetterCallback getter
, SetterCallback setter = 0
, v8::Local<v8::Value> data = v8::Local<v8::Value>()
+#if (NODE_MODULE_VERSION < NODE_21_0_MODULE_VERSION)
, v8::AccessControl settings = v8::DEFAULT
+#endif
, v8::PropertyAttribute attribute = v8::None) {
HandleScope scope;
@@ -2599,14 +2615,25 @@ inline void SetAccessor(
obj->SetInternalField(imp::kDataIndex, data);
}
+#if (NODE_MODULE_VERSION >= NODE_21_0_MODULE_VERSION)
+ tpl->SetNativeDataProperty(
+ name
+ , getter_
+ , setter_
+ , obj
+ , attribute);
+#else
tpl->SetAccessor(
name
, getter_
, setter_
, obj
+#if (NODE_MODULE_VERSION < NODE_21_0_MODULE_VERSION)
, settings
+#endif
, attribute
);
+#endif
}
inline bool SetAccessor(
@@ -2642,7 +2669,15 @@ inline bool SetAccessor(
, New<v8::External>(reinterpret_cast<void *>(setter)));
}
-#if (NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION)
+#if (NODE_MODULE_VERSION >= NODE_21_0_MODULE_VERSION)
+ return obj->SetNativeDataProperty(
+ GetCurrentContext()
+ , name
+ , getter_
+ , setter_
+ , dataobj
+ , attribute).FromMaybe(false);
+#elif (NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION)
return obj->SetAccessor(
GetCurrentContext()
, name
diff --git a/test/js/accessors-test.js b/test/js/accessors-test.js
index e6ad45737e2ac18da3fa936b1de618e7389933bc..025f5b66774c2f5fe0ccb98c91fc714dd916fcb1 100644
--- a/test/js/accessors-test.js
+++ b/test/js/accessors-test.js
@@ -11,7 +11,7 @@ const test = require('tap').test
, bindings = require('bindings')({ module_root: testRoot, bindings: 'accessors' });
test('accessors', function (t) {
- t.plan(7)
+ t.plan(6)
var settergetter = bindings.create()
t.equal(settergetter.prop1, 'this is property 1')
t.ok(settergetter.prop2 === '')
@@ -28,5 +28,4 @@ test('accessors', function (t) {
t.equal(derived.prop1, 'this is property 1')
derived.prop2 = 'setting a new value'
t.equal(derived.prop2, 'setting a new value')
- t.equal(settergetter.prop2, 'setting a new value')
})

View File

@@ -1,30 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: John Kleinschmidt <jkleinsc@electronjs.org>
Date: Fri, 28 Feb 2025 11:17:01 -0500
Subject: chore remove deprecated FunctionCallbackInfo Holder
v8 version 13.5.191 removed the deprecated FunctionCallbackInfo::Holder().
Callers are supposed to use FunctionCallbackInfo::This() instead.
See https://chromium-review.googlesource.com/c/v8/v8/+/6309166
diff --git a/nan_callbacks_12_inl.h b/nan_callbacks_12_inl.h
index 1af2459efcf54fa97ff24aaa221892eede6eb0d3..e8505247a5070dba572954ba63bc193c9fd51eb6 100644
--- a/nan_callbacks_12_inl.h
+++ b/nan_callbacks_12_inl.h
@@ -109,7 +109,14 @@ class FunctionCallbackInfo {
inline v8::Local<v8::Function> Callee() const { return info_.Callee(); }
#endif
inline v8::Local<v8::Value> Data() const { return data_; }
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION < 13 || \
+(V8_MAJOR_VERSION == 13 && defined(V8_MINOR_VERSION) && \
+(V8_MINOR_VERSION < 5 || (V8_MINOR_VERSION == 5 && \
+defined(V8_BUILD_NUMBER) && V8_BUILD_NUMBER < 191))))
inline v8::Local<v8::Object> Holder() const { return info_.Holder(); }
+#else
+ inline v8::Local<v8::Object> Holder() const { return info_.This(); }
+#endif
inline bool IsConstructCall() const { return info_.IsConstructCall(); }
inline int Length() const { return info_.Length(); }
inline v8::Local<v8::Value> operator[](int i) const { return info_[i]; }

View File

@@ -14,10 +14,10 @@ succeeded or not which was incorrect.
This should be upstreamed.
diff --git a/test/cpp/indexedinterceptors.cpp b/test/cpp/indexedinterceptors.cpp
index f2cd97ac9c40070c127bf9d682401c33955d6d6a..38f1298c2b44130eca73d9d005d2d7ab5f234926 100644
index 11f573f15109620c5105f1c212a5555bedd7e246..19b7673ff4c07236b11e1947d805979c21a0876e 100644
--- a/test/cpp/indexedinterceptors.cpp
+++ b/test/cpp/indexedinterceptors.cpp
@@ -90,9 +90,9 @@ NAN_INDEX_SETTER(IndexedInterceptor::PropertySetter) {
@@ -91,9 +91,9 @@ NAN_INDEX_SETTER(IndexedInterceptor::PropertySetter) {
interceptor->buf
, *Nan::Utf8String(value)
, sizeof (interceptor->buf));
@@ -27,21 +27,21 @@ index f2cd97ac9c40070c127bf9d682401c33955d6d6a..38f1298c2b44130eca73d9d005d2d7ab
- info.GetReturnValue().Set(info.This());
+ info.GetReturnValue().Set(True());
}
return Intercepted::Yes();
}
diff --git a/test/cpp/namedinterceptors.cpp b/test/cpp/namedinterceptors.cpp
index 8ab5f47db4b9830dd18c36d1a7cb0fced5925355..ae67f2391906fa0e9a60bc406bde86550965dab9 100644
index 4d8bf5c56ad888234e789f638859142ec92c0fd8..9f4b3b2000188fbeb53a5ec53969226916bac9da 100644
--- a/test/cpp/namedinterceptors.cpp
+++ b/test/cpp/namedinterceptors.cpp
@@ -90,10 +90,8 @@ NAN_PROPERTY_SETTER(NamedInterceptor::PropertySetter) {
@@ -91,9 +91,9 @@ NAN_PROPERTY_SETTER(NamedInterceptor::PropertySetter) {
interceptor->buf
, *Nan::Utf8String(value)
, sizeof (interceptor->buf));
- info.GetReturnValue().Set(info.This());
- } else {
+ info.GetReturnValue().Set(True());
} else {
- info.GetReturnValue().Set(info.This());
+ info.GetReturnValue().Set(True());
}
+ info.GetReturnValue().Set(True());
return Intercepted::Yes();
}
NAN_PROPERTY_ENUMERATOR(NamedInterceptor::PropertyEnumerator) {

View File

@@ -1,44 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: deepak1556 <hop2deep@gmail.com>
Date: Fri, 12 Apr 2024 22:16:58 +0900
Subject: fix: define Nan::CopyablePersistentTraits for v8 >= 12.5
Refs https://chromium-review.googlesource.com/c/v8/v8/+/5403708
Should be upstreamed.
diff --git a/nan.h b/nan.h
index 2a68349448c163fa29af327a03b11678e61f5789..42285328055ddb7c76548258f3c4847d2c278ad6 100644
--- a/nan.h
+++ b/nan.h
@@ -203,9 +203,11 @@ typedef v8::String::ExternalOneByteStringResource
template<typename T>
class NonCopyablePersistentTraits :
public v8::NonCopyablePersistentTraits<T> {};
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION <= 12 && V8_MINOR_VERSION < 5)
template<typename T>
class CopyablePersistentTraits :
public v8::CopyablePersistentTraits<T> {};
+#endif
template<typename T>
class PersistentBase :
diff --git a/nan_persistent_12_inl.h b/nan_persistent_12_inl.h
index d9649e867606c6356e393e9964b5607a08ea4e3a..ad89657e204259018f1e3814a864410a0917a915 100644
--- a/nan_persistent_12_inl.h
+++ b/nan_persistent_12_inl.h
@@ -129,4 +129,15 @@ class Global : public v8::UniquePersistent<T> {
};
#endif
+#if defined(V8_MAJOR_VERSION) && ((V8_MAJOR_VERSION >= 12 && V8_MINOR_VERSION >= 5) || V8_MAJOR_VERSION >= 13)
+template<typename T>
+struct CopyablePersistentTraits {
+ typedef v8::Persistent<T, CopyablePersistentTraits<T> > CopyablePersistent;
+ static const bool kResetInDestructor = true;
+ template<typename S, typename M>
+ static inline void Copy(const v8::Persistent<S, M> &source,
+ CopyablePersistent *dest) {}
+};
+#endif
+
#endif // NAN_PERSISTENT_12_INL_H_

View File

@@ -8,7 +8,7 @@ https://chromium-review.googlesource.com/c/v8/v8/+/6983465
Replaces the deprecated usage of SetPrototype.
diff --git a/nan_maybe_43_inl.h b/nan_maybe_43_inl.h
index c04ce30d2fa3bfb555c96754d93de64e8a83e36b..aa06dbad2f0b3d564917dbcd29ac608ad468327b 100644
index f37ce9732d556b58e4b755e1688cfb481ee40b61..8c3362e5d9dfeac385089100bf6414f628a98f33 100644
--- a/nan_maybe_43_inl.h
+++ b/nan_maybe_43_inl.h
@@ -207,7 +207,7 @@ inline Maybe<bool> SetPrototype(
@@ -21,7 +21,7 @@ index c04ce30d2fa3bfb555c96754d93de64e8a83e36b..aa06dbad2f0b3d564917dbcd29ac608a
inline MaybeLocal<v8::String> ObjectProtoToString(
diff --git a/nan_maybe_pre_43_inl.h b/nan_maybe_pre_43_inl.h
index 83325ae0897f95f2fe5354e9ab720796a7cefd7c..c309ace8c69feb6d01f136d4c0a33443886c467a 100644
index 84e2c11c26d5706bf345d347bc405b90bd14607c..4e0cfa183405142aa3013080d0f938dd2d731168 100644
--- a/nan_maybe_pre_43_inl.h
+++ b/nan_maybe_pre_43_inl.h
@@ -174,7 +174,7 @@ MaybeLocal<v8::Array> GetOwnPropertyNames(v8::Handle<v8::Object> obj) {

View File

@@ -6,10 +6,10 @@ Subject: fix: replace usage of removed WriteUtf8 with WriteUtf8V2
Refs https://chromium-review.googlesource.com/c/v8/v8/+/6495189
diff --git a/nan.h b/nan.h
index f4865a77e60d5105ed2426037984ddcbfa58bbca..d0b3e919f275bd4451eef9ad6aa1a78629ce862c 100644
index f0bfc0c6cc01b97156cb900615ec2df4b70ef5e8..0f120365630e7e2a37964f09cc129d05c6648c90 100644
--- a/nan.h
+++ b/nan.h
@@ -418,12 +418,18 @@ template<typename P> class WeakCallbackInfo;
@@ -427,12 +427,18 @@ template<typename P> class WeakCallbackInfo;
namespace imp {
static const size_t kMaxLength = 0x3fffffff;
@@ -31,7 +31,7 @@ index f4865a77e60d5105ed2426037984ddcbfa58bbca..d0b3e919f275bd4451eef9ad6aa1a786
static const unsigned kReplaceInvalidUtf8 = v8::String::REPLACE_INVALID_UTF8;
#else
static const unsigned kReplaceInvalidUtf8 = 0;
@@ -1157,11 +1163,11 @@ class Utf8String {
@@ -1167,11 +1173,11 @@ class Utf8String {
str_ = static_cast<char*>(malloc(len));
assert(str_ != 0);
}
@@ -47,7 +47,7 @@ index f4865a77e60d5105ed2426037984ddcbfa58bbca..d0b3e919f275bd4451eef9ad6aa1a786
#else
// See https://github.com/nodejs/nan/issues/832.
// Disable the warning as there is no way around it.
@@ -1173,6 +1179,8 @@ class Utf8String {
@@ -1183,6 +1189,8 @@ class Utf8String {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
@@ -56,7 +56,7 @@ index f4865a77e60d5105ed2426037984ddcbfa58bbca..d0b3e919f275bd4451eef9ad6aa1a786
length_ = string->WriteUtf8(str_, static_cast<int>(len), 0, flags);
#ifdef __GNUC__
#pragma GCC diagnostic pop
@@ -1499,9 +1507,10 @@ class Utf8String {
@@ -1509,9 +1517,10 @@ class Utf8String {
str_ = static_cast<char*>(malloc(len));
assert(str_ != 0);
}

View File

@@ -1,220 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <marshallofsound@electronjs.org>
Date: Fri, 28 Jun 2024 11:45:44 -0700
Subject: fix: support new variant of NamedPropertyHandlerConfiguration and
IndexedPropertyHandlerConfiguration
Ref: https://chromium-review.googlesource.com/c/v8/v8/+/5630388
This should be upstreamed, the reinterpret_cast is funky but works, but require more review when upstreaming.
diff --git a/nan_callbacks_12_inl.h b/nan_callbacks_12_inl.h
index bbcde4d65dec73139fee53339f154babd8f83b28..1af2459efcf54fa97ff24aaa221892eede6eb0d3 100644
--- a/nan_callbacks_12_inl.h
+++ b/nan_callbacks_12_inl.h
@@ -255,7 +255,98 @@ typedef void (*NativeSetter)(
, const v8::PropertyCallbackInfo<void> &);
#endif
-#if NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION
+#if NODE_MODULE_VERSION > NODE_21_0_MODULE_VERSION
+static
+v8::Intercepted PropertyGetterCallbackWrapper(
+ v8::Local<v8::Name> property
+ , const v8::PropertyCallbackInfo<v8::Value> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Value>
+ cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
+ PropertyGetterCallback callback = reinterpret_cast<PropertyGetterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kPropertyGetterIndex)
+ .As<v8::Value>().As<v8::External>()->Value()));
+ callback(property.As<v8::String>(), cbinfo);
+ return v8::Intercepted::kYes;
+}
+
+typedef v8::Intercepted (*NativePropertyGetter)
+ (v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value> &);
+
+static
+v8::Intercepted PropertySetterCallbackWrapper(
+ v8::Local<v8::Name> property
+ , v8::Local<v8::Value> value
+ , const v8::PropertyCallbackInfo<void> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<void>
+ cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
+ PropertySetterCallback callback = reinterpret_cast<PropertySetterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kPropertySetterIndex)
+ .As<v8::Value>().As<v8::External>()->Value()));
+ callback(property.As<v8::String>(), value, *reinterpret_cast<PropertyCallbackInfo<v8::Value>*>(&cbinfo));
+ return v8::Intercepted::kYes;
+}
+
+typedef v8::Intercepted (*NativePropertySetter)(
+ v8::Local<v8::Name>
+ , v8::Local<v8::Value>
+ , const v8::PropertyCallbackInfo<void> &);
+
+static
+void PropertyEnumeratorCallbackWrapper(
+ const v8::PropertyCallbackInfo<v8::Array> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Array>
+ cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
+ PropertyEnumeratorCallback callback =
+ reinterpret_cast<PropertyEnumeratorCallback>(reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kPropertyEnumeratorIndex)
+ .As<v8::Value>().As<v8::External>()->Value()));
+ callback(cbinfo);
+}
+
+typedef void (*NativePropertyEnumerator)
+ (const v8::PropertyCallbackInfo<v8::Array> &);
+
+static
+v8::Intercepted PropertyDeleterCallbackWrapper(
+ v8::Local<v8::Name> property
+ , const v8::PropertyCallbackInfo<v8::Boolean> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Boolean>
+ cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
+ PropertyDeleterCallback callback = reinterpret_cast<PropertyDeleterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kPropertyDeleterIndex)
+ .As<v8::Value>().As<v8::External>()->Value()));
+ callback(property.As<v8::String>(), cbinfo);
+ return v8::Intercepted::kYes;
+}
+
+typedef v8::Intercepted (NativePropertyDeleter)
+ (v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Boolean> &);
+
+static
+v8::Intercepted PropertyQueryCallbackWrapper(
+ v8::Local<v8::Name> property
+ , const v8::PropertyCallbackInfo<v8::Integer> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Integer>
+ cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
+ PropertyQueryCallback callback = reinterpret_cast<PropertyQueryCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kPropertyQueryIndex)
+ .As<v8::Value>().As<v8::External>()->Value()));
+ callback(property.As<v8::String>(), cbinfo);
+ return v8::Intercepted::kYes;
+}
+
+typedef v8::Intercepted (*NativePropertyQuery)
+ (v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Integer> &);
+#elif NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION
static
void PropertyGetterCallbackWrapper(
v8::Local<v8::Name> property
@@ -431,6 +522,96 @@ typedef void (*NativePropertyQuery)
(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Integer> &);
#endif
+#if NODE_MODULE_VERSION > NODE_21_0_MODULE_VERSION
+static
+v8::Intercepted IndexGetterCallbackWrapper(
+ uint32_t index, const v8::PropertyCallbackInfo<v8::Value> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Value>
+ cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
+ IndexGetterCallback callback = reinterpret_cast<IndexGetterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kIndexPropertyGetterIndex)
+ .As<v8::Value>().As<v8::External>()->Value()));
+ callback(index, cbinfo);
+ return v8::Intercepted::kYes;
+}
+
+typedef v8::Intercepted (*NativeIndexGetter)
+ (uint32_t, const v8::PropertyCallbackInfo<v8::Value> &);
+
+static
+v8::Intercepted IndexSetterCallbackWrapper(
+ uint32_t index
+ , v8::Local<v8::Value> value
+ , const v8::PropertyCallbackInfo<void> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<void>
+ cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
+ IndexSetterCallback callback = reinterpret_cast<IndexSetterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kIndexPropertySetterIndex)
+ .As<v8::Value>().As<v8::External>()->Value()));
+ callback(index, value, *reinterpret_cast<PropertyCallbackInfo<v8::Value>*>(&cbinfo));
+ return v8::Intercepted::kYes;
+}
+
+typedef v8::Intercepted (*NativeIndexSetter)(
+ uint32_t
+ , v8::Local<v8::Value>
+ , const v8::PropertyCallbackInfo<void> &);
+
+static
+void IndexEnumeratorCallbackWrapper(
+ const v8::PropertyCallbackInfo<v8::Array> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Array>
+ cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
+ IndexEnumeratorCallback callback = reinterpret_cast<IndexEnumeratorCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(
+ kIndexPropertyEnumeratorIndex)
+ .As<v8::Value>().As<v8::External>()->Value()));
+ callback(cbinfo);
+}
+
+typedef void (*NativeIndexEnumerator)
+ (const v8::PropertyCallbackInfo<v8::Array> &);
+
+static
+v8::Intercepted IndexDeleterCallbackWrapper(
+ uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Boolean>
+ cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
+ IndexDeleterCallback callback = reinterpret_cast<IndexDeleterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kIndexPropertyDeleterIndex)
+ .As<v8::Value>().As<v8::External>()->Value()));
+ callback(index, cbinfo);
+ return v8::Intercepted::kYes;
+}
+
+typedef v8::Intercepted (*NativeIndexDeleter)
+ (uint32_t, const v8::PropertyCallbackInfo<v8::Boolean> &);
+
+static
+v8::Intercepted IndexQueryCallbackWrapper(
+ uint32_t index, const v8::PropertyCallbackInfo<v8::Integer> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Integer>
+ cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
+ IndexQueryCallback callback = reinterpret_cast<IndexQueryCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kIndexPropertyQueryIndex)
+ .As<v8::Value>().As<v8::External>()->Value()));
+ callback(index, cbinfo);
+ return v8::Intercepted::kYes;
+}
+
+typedef v8::Intercepted (*NativeIndexQuery)
+ (uint32_t, const v8::PropertyCallbackInfo<v8::Integer> &);
+#else
static
void IndexGetterCallbackWrapper(
uint32_t index, const v8::PropertyCallbackInfo<v8::Value> &info) {
@@ -515,6 +696,8 @@ void IndexQueryCallbackWrapper(
typedef void (*NativeIndexQuery)
(uint32_t, const v8::PropertyCallbackInfo<v8::Integer> &);
+#endif
+
} // end of namespace imp
#endif // NAN_CALLBACKS_12_INL_H_

View File

@@ -1,28 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: John Kleinschmidt <jkleinsc@electronjs.org>
Date: Thu, 6 Jun 2024 15:16:49 -0400
Subject: Remove deprecated v8::Isolate::IdleNotificationDeadline
See https://chromium-review.googlesource.com/c/v8/v8/+/5539852
Also https://github.com/nodejs/nan/issues/953#issuecomment-1791163429
diff --git a/nan.h b/nan.h
index 42285328055ddb7c76548258f3c4847d2c278ad6..9a9112afe0cc94ce58ed3cce9763ace7c160a932 100644
--- a/nan.h
+++ b/nan.h
@@ -684,7 +684,13 @@ inline uv_loop_t* GetCurrentEventLoop() {
v8::Isolate::GetCurrent()->SetAddHistogramSampleFunction(cb);
}
-#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 11 || \
+ (V8_MAJOR_VERSION == 11 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
+ inline bool IdleNotification(int idle_time_in_ms) {
+ v8::Isolate::GetCurrent()->MemoryPressureNotification(v8::MemoryPressureLevel::kModerate);
+ return true;
+ }
+#elif defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
inline bool IdleNotification(int idle_time_in_ms) {
return v8::Isolate::GetCurrent()->IdleNotificationDeadline(

View File

@@ -1,41 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: John Kleinschmidt <jkleinsc@electronjs.org>
Date: Thu, 6 Jun 2024 15:17:39 -0400
Subject: Remove several APIs deprecated in version 12.6
See https://chromium-review.googlesource.com/c/v8/v8/+/5539888
ScriptOrigin constructor with isolate has been removed;
Deprecation instructions were to "Use constructor without the isolate."
diff --git a/nan_scriptorigin.h b/nan_scriptorigin.h
index ce79cdf8dc931d61633c74079a4c38efd3c785ed..85202aaba148540644d39ea2cdf88de0dd101fe4 100644
--- a/nan_scriptorigin.h
+++ b/nan_scriptorigin.h
@@ -11,7 +11,25 @@
class ScriptOrigin : public v8::ScriptOrigin {
public:
-#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 9 || \
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 12 || \
+ (V8_MAJOR_VERSION == 12 && (defined(V8_MINOR_VERSION) && (V8_MINOR_VERSION > 6\
+ || (V8_MINOR_VERSION == 7 && defined(V8_BUILD_NUMBER) \
+ && V8_BUILD_NUMBER >= 1)))))
+ explicit ScriptOrigin(v8::Local<v8::Value> name) :
+ v8::ScriptOrigin(name) {}
+
+ ScriptOrigin(v8::Local<v8::Value> name
+ , v8::Local<v8::Integer> line) :
+ v8::ScriptOrigin(name
+ , To<int32_t>(line).FromMaybe(0)) {}
+
+ ScriptOrigin(v8::Local<v8::Value> name
+ , v8::Local<v8::Integer> line
+ , v8::Local<v8::Integer> column) :
+ v8::ScriptOrigin(name
+ , To<int32_t>(line).FromMaybe(0)
+ , To<int32_t>(column).FromMaybe(0)) {}
+#elif defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 9 || \
(V8_MAJOR_VERSION == 9 && (defined(V8_MINOR_VERSION) && (V8_MINOR_VERSION > 0\
|| (V8_MINOR_VERSION == 0 && defined(V8_BUILD_NUMBER) \
&& V8_BUILD_NUMBER >= 1)))))

View File

@@ -0,0 +1,61 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Calvin Watford <clavin@electronjs.org>
Date: Mon, 20 Oct 2025 10:04:13 -0600
Subject: test: use v8 version check instead of node version check
A few tests use a Node.js version check to determine expected V8
behavior, but since Electron ships with a different V8 version than
Node.js, this can lead to incorrect test expectations. This change
updates the tests to use the V8 version directly for more accurate
results.
The existing check was for Node.js version > 22. Node.js v22 ships with
V8 v12.4, and Node.js v23 ships with V8 v12.9. So, the new check uses
V8 version >= 12.9 to match the previous behavior. The actual V8
behavior change may have occurred somewhere between those versions, so
further work should verify the exact cutoff.
This patch should be upstreamed. The only additional work is to verify
the V8 version to check against.
diff --git a/test/js/accessors-test.js b/test/js/accessors-test.js
index 85ff490c0a23277f54ceaeae2f98ceb24f4d5727..21064e1eae8d64c79a0e77a3785945a9b49e60c4 100644
--- a/test/js/accessors-test.js
+++ b/test/js/accessors-test.js
@@ -9,12 +9,12 @@
const test = require('tap').test
, testRoot = require('path').resolve(__dirname, '..')
, bindings = require('bindings')({ module_root: testRoot, bindings: 'accessors' });
-const nodeVersion = parseInt(process.versions.node.split('.')[0]);
+const v8Version = process.versions.v8.split('.').map(parseInt);
test('accessors', function (t) {
var settergetter = bindings.create()
var derived = Object.create(settergetter)
- if(nodeVersion > 22){
+ if(v8Version[0] > 12 || (v8Version[0] === 12 && v8Version[1] >= 9)) {
t.plan(9)
t.equal(settergetter.prop1, 'this is property 1')
t.ok(settergetter.prop2 === '')
diff --git a/test/js/methodswithdata-test.js b/test/js/methodswithdata-test.js
index dec024a3d8b6a117d0d0a20ffa13e25088938dc9..8458272def0739c3edc111e6122f676b44e04fd7 100644
--- a/test/js/methodswithdata-test.js
+++ b/test/js/methodswithdata-test.js
@@ -9,7 +9,7 @@
const test = require('tap').test
, testRoot = require('path').resolve(__dirname, '..')
, bindings = require('bindings')({ module_root: testRoot, bindings: 'methodswithdata' })
-const nodeVersion = parseInt(process.versions.node.split('.')[0]);
+const v8Version = process.versions.v8.split('.').map(parseInt);
test('SetMethod with data', function (t) {
t.plan(1);
@@ -19,7 +19,7 @@ test('SetMethod with data', function (t) {
test('accessors with data', function (t) {
var settergetter = bindings.create()
var derived = Object.create(settergetter)
- if (nodeVersion > 22) {
+ if(v8Version[0] > 12 || (v8Version[0] === 12 && v8Version[1] >= 9)) {
t.plan(9)
t.equal(settergetter.prop1, 'this is property 1')
t.ok(settergetter.prop2 === '')

View File

@@ -1,33 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Rose <japthorp@slack-corp.com>
Date: Thu, 5 May 2022 14:14:36 -0700
Subject: use new constructor for ScriptOrigin when >= 17.x
https://chromium-review.googlesource.com/c/v8/v8/+/3395880
Also
See https://chromium-review.googlesource.com/c/v8/v8/+/5539888
ScriptOrigin constructor with isolate has been removed;
diff --git a/test/cpp/news.cpp b/test/cpp/news.cpp
index a218167c7e3a5ec90c6668943cb395dba2bbe3a7..b1fa6e2a77e926e38006bf47ffcda2ae86555d17 100644
--- a/test/cpp/news.cpp
+++ b/test/cpp/news.cpp
@@ -115,7 +115,7 @@ NAN_METHOD(NewScript) {
NAN_METHOD(NewScript2) {
v8::ScriptOrigin origin(
-#if NODE_MODULE_VERSION >= NODE_18_0_MODULE_VERSION
+#if NODE_MODULE_VERSION >= NODE_17_0_MODULE_VERSION && NODE_MODULE_VERSION < NODE_20_0_MODULE_VERSION
info.GetIsolate(),
#endif
New<v8::String>("x").ToLocalChecked());
@@ -136,7 +136,7 @@ NAN_METHOD(CompileScript) {
NAN_METHOD(CompileScript2) {
v8::ScriptOrigin origin(
-#if NODE_MODULE_VERSION >= NODE_18_0_MODULE_VERSION
+#if NODE_MODULE_VERSION >= NODE_17_0_MODULE_VERSION && NODE_MODULE_VERSION < NODE_20_0_MODULE_VERSION
info.GetIsolate(),
#endif
New<v8::String>("x").ToLocalChecked());

View File

@@ -65,6 +65,12 @@ async function main () {
platformFlags.push(`-isysroot ${path.resolve(sdkPath, sdkToUse)}`);
}
const cflags = [
'-Wno-trigraphs',
'-fPIC',
...platformFlags
].join(' ');
const cxxflags = [
'-std=c++20',
'-Wno-trigraphs',
@@ -92,10 +98,10 @@ async function main () {
if (process.platform !== 'win32') {
env.CC = cc;
env.CFLAGS = cxxflags;
env.CFLAGS = cflags;
env.CXX = cxx;
env.LD = ld;
env.CXXFLAGS = cxxflags;
env.LD = ld;
env.LDFLAGS = ldflags;
}
@@ -129,9 +135,9 @@ async function main () {
const DISABLED_TESTS = new Set([
'nannew-test.js',
'buffer-test.js',
// we can't patch this test because it uses CRLF line endings
'methodswithdata-test.js',
// these two are incompatible with crrev.com/c/4733273
// These two are incompatible with crrev.com/c/4733273
// They are disabled upstream starting in "Node.js 24" (note: the incompatible change above
// landed in V8 v13.7), so we can remove them from this list once we upgrade Node.js to 24.
'weak-test.js',
'weak2-test.js'
]);