From f8e4970d33c10d7c1689fe43106628af3949ca8f Mon Sep 17 00:00:00 2001 From: tstone-1 Date: Fri, 13 Mar 2026 08:49:23 +0100 Subject: [PATCH] fix: use HolderV2() for PropertyCallbackInfo on V8 >= 13 PR #1456 replaced This() with Holder() in NODE_GETTER contexts, but Electron 41 (V8 14.6) removed both This() and Holder() from PropertyCallbackInfo. Only HolderV2() remains (to be renamed back to Holder() in a future V8 version per crbug.com/333672197). Add a PROPERTY_HOLDER compat macro that uses HolderV2() on V8 >= 13 and falls back to This() on older versions. Same pattern as the existing GET_PROTOTYPE macro. Verified: compiles and runs on Electron 41.0.1 (V8 14.6.202). Fixes #1458 --- src/objects/database.cpp | 4 ++-- src/objects/statement.cpp | 2 +- src/util/macros.cpp | 13 +++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/objects/database.cpp b/src/objects/database.cpp index 32df804d3..232461169 100644 --- a/src/objects/database.cpp +++ b/src/objects/database.cpp @@ -408,10 +408,10 @@ NODE_METHOD(Database::JS_unsafeMode) { } NODE_GETTER(Database::JS_open) { - info.GetReturnValue().Set(Unwrap(info.Holder())->open); + info.GetReturnValue().Set(Unwrap(PROPERTY_HOLDER(info))->open); } NODE_GETTER(Database::JS_inTransaction) { - Database* db = Unwrap(info.Holder()); + Database* db = Unwrap(PROPERTY_HOLDER(info)); info.GetReturnValue().Set(db->open && !static_cast(sqlite3_get_autocommit(db->db_handle))); } diff --git a/src/objects/statement.cpp b/src/objects/statement.cpp index 61c6645ef..918fa6919 100644 --- a/src/objects/statement.cpp +++ b/src/objects/statement.cpp @@ -378,6 +378,6 @@ NODE_METHOD(Statement::JS_columns) { } NODE_GETTER(Statement::JS_busy) { - Statement* stmt = Unwrap(info.Holder()); + Statement* stmt = Unwrap(PROPERTY_HOLDER(info)); info.GetReturnValue().Set(stmt->alive && stmt->locked); } diff --git a/src/util/macros.cpp b/src/util/macros.cpp index 5adf749d2..e75d53763 100644 --- a/src/util/macros.cpp +++ b/src/util/macros.cpp @@ -11,6 +11,19 @@ #define GET_PROTOTYPE(obj) ((obj)->GetPrototype()) #endif +// PropertyCallbackInfo::This() and Holder() were removed; use HolderV2(). +// Tracking bug for V8 API removals: http://crbug.com/333672197 +// V8 head has since restored Holder() and deprecated HolderV2(): +// https://chromium.googlesource.com/v8/v8/+/main/include/v8-function-callback.h +// V8_INLINE Local Holder() const; +// V8_DEPRECATE_SOON("Use Holder().") +// V8_INLINE Local HolderV2() const; +#if defined(V8_MAJOR_VERSION) && V8_MAJOR_VERSION >= 13 +#define PROPERTY_HOLDER(info) (info).HolderV2() +#else +#define PROPERTY_HOLDER(info) (info).This() +#endif + #define EasyIsolate v8::Isolate* isolate = v8::Isolate::GetCurrent() #define OnlyIsolate info.GetIsolate() #define OnlyContext isolate->GetCurrentContext()