From 1baa513cf94b28a9b5c68046ff4213614cf32c35 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Tue, 12 Nov 2024 11:20:38 +0100 Subject: [PATCH 1/3] fix: Unwrap a lot of NITRO_DEBUGs --- .../android/src/main/cpp/platform/NitroLogger.cpp | 2 -- .../src/main/cpp/registry/DefaultConstructableObject.hpp | 2 -- .../android/src/main/cpp/registry/JHybridObjectRegistry.cpp | 2 -- .../react-native-nitro-modules/cpp/core/HybridFunction.hpp | 2 -- packages/react-native-nitro-modules/cpp/jsi/JSICache.cpp | 2 -- .../cpp/jsi/JSIConverter+ArrayBuffer.hpp | 4 ---- .../cpp/jsi/JSIConverter+HostObject.hpp | 4 ---- .../cpp/jsi/JSIConverter+HybridObject.hpp | 4 ---- .../cpp/registry/HybridObjectRegistry.cpp | 2 -- 9 files changed, 24 deletions(-) diff --git a/packages/react-native-nitro-modules/android/src/main/cpp/platform/NitroLogger.cpp b/packages/react-native-nitro-modules/android/src/main/cpp/platform/NitroLogger.cpp index a87d5f8c3..1f47ad17c 100644 --- a/packages/react-native-nitro-modules/android/src/main/cpp/platform/NitroLogger.cpp +++ b/packages/react-native-nitro-modules/android/src/main/cpp/platform/NitroLogger.cpp @@ -27,11 +27,9 @@ int levelToAndroidLevel(LogLevel level) { } void Logger::nativeLog(LogLevel level, const char* tag, const std::string& message) { -#ifdef NITRO_DEBUG int logLevel = levelToAndroidLevel(level); std::string combinedTag = "Nitro." + std::string(tag); __android_log_print(logLevel, combinedTag.c_str(), "%s", message.c_str()); -#endif } } // namespace margelo::nitro diff --git a/packages/react-native-nitro-modules/android/src/main/cpp/registry/DefaultConstructableObject.hpp b/packages/react-native-nitro-modules/android/src/main/cpp/registry/DefaultConstructableObject.hpp index 959bd8148..4f93698fa 100644 --- a/packages/react-native-nitro-modules/android/src/main/cpp/registry/DefaultConstructableObject.hpp +++ b/packages/react-native-nitro-modules/android/src/main/cpp/registry/DefaultConstructableObject.hpp @@ -57,11 +57,9 @@ class DefaultConstructableObject { jni::local_ref create() const { // Calls the class's default constructor auto instance = _javaClass->newObject(_defaultConstructor); -#ifdef NITRO_DEBUG if (instance == nullptr) [[unlikely]] { throw std::runtime_error("Failed to create an instance of \"JHybridTestObjectSwiftKotlinSpec\" - the constructor returned null!"); } -#endif return instance; } diff --git a/packages/react-native-nitro-modules/android/src/main/cpp/registry/JHybridObjectRegistry.cpp b/packages/react-native-nitro-modules/android/src/main/cpp/registry/JHybridObjectRegistry.cpp index 2757d6769..e7211bd43 100644 --- a/packages/react-native-nitro-modules/android/src/main/cpp/registry/JHybridObjectRegistry.cpp +++ b/packages/react-native-nitro-modules/android/src/main/cpp/registry/JHybridObjectRegistry.cpp @@ -18,11 +18,9 @@ void JHybridObjectRegistry::registerHybridObjectConstructor(jni::alias_ref std::shared_ptr { // 1. Call the Java initializer function jni::local_ref hybridObject = sharedInitializer->call(); -#ifdef NITRO_DEBUG if (hybridObject == nullptr) [[unlikely]] { throw std::runtime_error("Failed to create HybridObject \"" + hybridObjectName + "\" - the constructor returned null!"); } -#endif // 2. Make the resulting HybridObject a global (shared) reference jni::global_ref globalHybridObject = jni::make_global(hybridObject); diff --git a/packages/react-native-nitro-modules/cpp/core/HybridFunction.hpp b/packages/react-native-nitro-modules/cpp/core/HybridFunction.hpp index 1f6a36461..87d8e493f 100644 --- a/packages/react-native-nitro-modules/cpp/core/HybridFunction.hpp +++ b/packages/react-native-nitro-modules/cpp/core/HybridFunction.hpp @@ -171,7 +171,6 @@ class HybridFunction final { static inline std::shared_ptr getHybridObjectNativeState(jsi::Runtime& runtime, const jsi::Value& value, FunctionKind funcKind, const std::string& funcName) { // 1. Convert jsi::Value to jsi::Object -#ifdef NITRO_DEBUG if (!value.isObject()) [[unlikely]] { throw jsi::JSError(runtime, "Cannot " + getHybridFuncDebugInfo(funcKind, funcName) + " - `this` is not bound! Suggestions:\n" @@ -182,7 +181,6 @@ class HybridFunction final { "- Did you accidentally call `" + funcName + "` on the prototype directly?"); } -#endif jsi::Object object = value.getObject(runtime); // 2. Check if it even has any kind of `NativeState` diff --git a/packages/react-native-nitro-modules/cpp/jsi/JSICache.cpp b/packages/react-native-nitro-modules/cpp/jsi/JSICache.cpp index 45958d06d..70148f370 100644 --- a/packages/react-native-nitro-modules/cpp/jsi/JSICache.cpp +++ b/packages/react-native-nitro-modules/cpp/jsi/JSICache.cpp @@ -47,11 +47,9 @@ JSICacheReference JSICache::getOrCreateCache(jsi::Runtime& runtime) { Logger::log(LogLevel::Warning, TAG, "JSICache was created, but it is no longer strong!"); } -#ifdef NITRO_DEBUG if (runtime.global().hasProperty(runtime, CACHE_PROP_NAME)) [[unlikely]] { throw std::runtime_error("The Runtime \"" + getRuntimeId(runtime) + "\" already has a global cache! (\"" + CACHE_PROP_NAME + "\")"); } -#endif // Cache doesn't exist yet. Logger::log(LogLevel::Info, TAG, "Creating new JSICache for runtime %s..", getRuntimeId(runtime).c_str()); diff --git a/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+ArrayBuffer.hpp b/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+ArrayBuffer.hpp index 121a06104..ecb4c1815 100644 --- a/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+ArrayBuffer.hpp +++ b/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+ArrayBuffer.hpp @@ -31,22 +31,18 @@ using namespace facebook; template struct JSIConverter>> final { static inline std::shared_ptr fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { -#ifdef NITRO_DEBUG if (!arg.isObject()) [[unlikely]] { throw std::invalid_argument("Value \"" + arg.toString(runtime).utf8(runtime) + "\" is not an ArrayBuffer - " "in fact, it's not even an object!"); } -#endif jsi::Object object = arg.asObject(runtime); -#ifdef NITRO_DEBUG if (!object.isArrayBuffer(runtime)) [[unlikely]] { throw std::invalid_argument("Object \"" + arg.toString(runtime).utf8(runtime) + "\" is not an ArrayBuffer! " "Are you maybe passing a TypedArray (e.g. Uint8Array)? Try to pass it's `.buffer` value."); } -#endif JSICacheReference cache = JSICache::getOrCreateCache(runtime); auto borrowingArrayBuffer = cache.makeShared(object.getArrayBuffer(runtime)); diff --git a/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+HostObject.hpp b/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+HostObject.hpp index 22cb8a392..1098e6a6e 100644 --- a/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+HostObject.hpp +++ b/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+HostObject.hpp @@ -20,7 +20,6 @@ struct JSIConverter>> using TPointee = typename T::element_type; static inline T fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { -#ifdef NITRO_DEBUG if (!arg.isObject()) [[unlikely]] { if (arg.isUndefined()) [[unlikely]] { throw jsi::JSError(runtime, invalidTypeErrorMessage("undefined", "It is undefined!")); @@ -29,10 +28,8 @@ struct JSIConverter>> throw jsi::JSError(runtime, invalidTypeErrorMessage(stringRepresentation, "It is not an object!")); } } -#endif jsi::Object object = arg.asObject(runtime); -#ifdef NITRO_DEBUG if (!object.isHostObject(runtime)) [[unlikely]] { if (!object.isHostObject(runtime)) [[unlikely]] { std::string stringRepresentation = arg.toString(runtime).utf8(runtime); @@ -42,7 +39,6 @@ struct JSIConverter>> throw jsi::JSError(runtime, invalidTypeErrorMessage(stringRepresentation, "It is a different HostObject!")); } } -#endif return object.getHostObject(runtime); } diff --git a/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+HybridObject.hpp b/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+HybridObject.hpp index b5c190db2..8720f7d43 100644 --- a/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+HybridObject.hpp +++ b/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+HybridObject.hpp @@ -25,7 +25,6 @@ struct JSIConverter> using TPointee = typename T::element_type; static inline T fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { -#ifdef NITRO_DEBUG if (!arg.isObject()) [[unlikely]] { if (arg.isUndefined()) [[unlikely]] { throw jsi::JSError(runtime, invalidTypeErrorMessage("undefined", "It is undefined!")); @@ -34,10 +33,8 @@ struct JSIConverter> throw jsi::JSError(runtime, invalidTypeErrorMessage(stringRepresentation, "It is not an object!")); } } -#endif jsi::Object object = arg.asObject(runtime); -#ifdef NITRO_DEBUG if (!object.hasNativeState(runtime)) [[unlikely]] { if (!object.hasNativeState(runtime)) [[unlikely]] { std::string stringRepresentation = arg.toString(runtime).utf8(runtime); @@ -47,7 +44,6 @@ struct JSIConverter> throw jsi::JSError(runtime, invalidTypeErrorMessage(stringRepresentation, "It has a different NativeState!")); } } -#endif std::shared_ptr nativeState = object.getNativeState(runtime); return std::dynamic_pointer_cast(nativeState); } diff --git a/packages/react-native-nitro-modules/cpp/registry/HybridObjectRegistry.cpp b/packages/react-native-nitro-modules/cpp/registry/HybridObjectRegistry.cpp index fc9397e81..bd783f36e 100644 --- a/packages/react-native-nitro-modules/cpp/registry/HybridObjectRegistry.cpp +++ b/packages/react-native-nitro-modules/cpp/registry/HybridObjectRegistry.cpp @@ -32,7 +32,6 @@ std::vector HybridObjectRegistry::getAllHybridObjectNames() { void HybridObjectRegistry::registerHybridObjectConstructor(const std::string& hybridObjectName, HybridObjectConstructorFn&& constructorFn) { Logger::log(LogLevel::Info, TAG, "Registering HybridObject \"%s\"...", hybridObjectName.c_str()); auto& map = HybridObjectRegistry::getRegistry(); -#ifdef NITRO_DEBUG if (map.contains(hybridObjectName)) [[unlikely]] { auto message = "HybridObject \"" + std::string(hybridObjectName) + @@ -42,7 +41,6 @@ void HybridObjectRegistry::registerHybridObjectConstructor(const std::string& hy "- If you just registered your own HybridObject, maybe you accidentally called `registerHybridObjectConstructor(...)` twice?"; throw std::runtime_error(message); } -#endif map.insert({hybridObjectName, std::move(constructorFn)}); Logger::log(LogLevel::Info, TAG, "Successfully registered HybridObject \"%s\"!", hybridObjectName.c_str()); } From e3e90e76ffcab819ddaf25c183ffd2772bb7ef10 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Tue, 12 Nov 2024 11:21:36 +0100 Subject: [PATCH 2/3] Revert "fix: Unwrap a lot of NITRO_DEBUGs" This reverts commit 1baa513cf94b28a9b5c68046ff4213614cf32c35. --- .../android/src/main/cpp/platform/NitroLogger.cpp | 2 ++ .../src/main/cpp/registry/DefaultConstructableObject.hpp | 2 ++ .../android/src/main/cpp/registry/JHybridObjectRegistry.cpp | 2 ++ .../react-native-nitro-modules/cpp/core/HybridFunction.hpp | 2 ++ packages/react-native-nitro-modules/cpp/jsi/JSICache.cpp | 2 ++ .../cpp/jsi/JSIConverter+ArrayBuffer.hpp | 4 ++++ .../cpp/jsi/JSIConverter+HostObject.hpp | 4 ++++ .../cpp/jsi/JSIConverter+HybridObject.hpp | 4 ++++ .../cpp/registry/HybridObjectRegistry.cpp | 2 ++ 9 files changed, 24 insertions(+) diff --git a/packages/react-native-nitro-modules/android/src/main/cpp/platform/NitroLogger.cpp b/packages/react-native-nitro-modules/android/src/main/cpp/platform/NitroLogger.cpp index 1f47ad17c..a87d5f8c3 100644 --- a/packages/react-native-nitro-modules/android/src/main/cpp/platform/NitroLogger.cpp +++ b/packages/react-native-nitro-modules/android/src/main/cpp/platform/NitroLogger.cpp @@ -27,9 +27,11 @@ int levelToAndroidLevel(LogLevel level) { } void Logger::nativeLog(LogLevel level, const char* tag, const std::string& message) { +#ifdef NITRO_DEBUG int logLevel = levelToAndroidLevel(level); std::string combinedTag = "Nitro." + std::string(tag); __android_log_print(logLevel, combinedTag.c_str(), "%s", message.c_str()); +#endif } } // namespace margelo::nitro diff --git a/packages/react-native-nitro-modules/android/src/main/cpp/registry/DefaultConstructableObject.hpp b/packages/react-native-nitro-modules/android/src/main/cpp/registry/DefaultConstructableObject.hpp index 4f93698fa..959bd8148 100644 --- a/packages/react-native-nitro-modules/android/src/main/cpp/registry/DefaultConstructableObject.hpp +++ b/packages/react-native-nitro-modules/android/src/main/cpp/registry/DefaultConstructableObject.hpp @@ -57,9 +57,11 @@ class DefaultConstructableObject { jni::local_ref create() const { // Calls the class's default constructor auto instance = _javaClass->newObject(_defaultConstructor); +#ifdef NITRO_DEBUG if (instance == nullptr) [[unlikely]] { throw std::runtime_error("Failed to create an instance of \"JHybridTestObjectSwiftKotlinSpec\" - the constructor returned null!"); } +#endif return instance; } diff --git a/packages/react-native-nitro-modules/android/src/main/cpp/registry/JHybridObjectRegistry.cpp b/packages/react-native-nitro-modules/android/src/main/cpp/registry/JHybridObjectRegistry.cpp index e7211bd43..2757d6769 100644 --- a/packages/react-native-nitro-modules/android/src/main/cpp/registry/JHybridObjectRegistry.cpp +++ b/packages/react-native-nitro-modules/android/src/main/cpp/registry/JHybridObjectRegistry.cpp @@ -18,9 +18,11 @@ void JHybridObjectRegistry::registerHybridObjectConstructor(jni::alias_ref std::shared_ptr { // 1. Call the Java initializer function jni::local_ref hybridObject = sharedInitializer->call(); +#ifdef NITRO_DEBUG if (hybridObject == nullptr) [[unlikely]] { throw std::runtime_error("Failed to create HybridObject \"" + hybridObjectName + "\" - the constructor returned null!"); } +#endif // 2. Make the resulting HybridObject a global (shared) reference jni::global_ref globalHybridObject = jni::make_global(hybridObject); diff --git a/packages/react-native-nitro-modules/cpp/core/HybridFunction.hpp b/packages/react-native-nitro-modules/cpp/core/HybridFunction.hpp index 87d8e493f..1f6a36461 100644 --- a/packages/react-native-nitro-modules/cpp/core/HybridFunction.hpp +++ b/packages/react-native-nitro-modules/cpp/core/HybridFunction.hpp @@ -171,6 +171,7 @@ class HybridFunction final { static inline std::shared_ptr getHybridObjectNativeState(jsi::Runtime& runtime, const jsi::Value& value, FunctionKind funcKind, const std::string& funcName) { // 1. Convert jsi::Value to jsi::Object +#ifdef NITRO_DEBUG if (!value.isObject()) [[unlikely]] { throw jsi::JSError(runtime, "Cannot " + getHybridFuncDebugInfo(funcKind, funcName) + " - `this` is not bound! Suggestions:\n" @@ -181,6 +182,7 @@ class HybridFunction final { "- Did you accidentally call `" + funcName + "` on the prototype directly?"); } +#endif jsi::Object object = value.getObject(runtime); // 2. Check if it even has any kind of `NativeState` diff --git a/packages/react-native-nitro-modules/cpp/jsi/JSICache.cpp b/packages/react-native-nitro-modules/cpp/jsi/JSICache.cpp index 70148f370..45958d06d 100644 --- a/packages/react-native-nitro-modules/cpp/jsi/JSICache.cpp +++ b/packages/react-native-nitro-modules/cpp/jsi/JSICache.cpp @@ -47,9 +47,11 @@ JSICacheReference JSICache::getOrCreateCache(jsi::Runtime& runtime) { Logger::log(LogLevel::Warning, TAG, "JSICache was created, but it is no longer strong!"); } +#ifdef NITRO_DEBUG if (runtime.global().hasProperty(runtime, CACHE_PROP_NAME)) [[unlikely]] { throw std::runtime_error("The Runtime \"" + getRuntimeId(runtime) + "\" already has a global cache! (\"" + CACHE_PROP_NAME + "\")"); } +#endif // Cache doesn't exist yet. Logger::log(LogLevel::Info, TAG, "Creating new JSICache for runtime %s..", getRuntimeId(runtime).c_str()); diff --git a/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+ArrayBuffer.hpp b/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+ArrayBuffer.hpp index ecb4c1815..121a06104 100644 --- a/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+ArrayBuffer.hpp +++ b/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+ArrayBuffer.hpp @@ -31,18 +31,22 @@ using namespace facebook; template struct JSIConverter>> final { static inline std::shared_ptr fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { +#ifdef NITRO_DEBUG if (!arg.isObject()) [[unlikely]] { throw std::invalid_argument("Value \"" + arg.toString(runtime).utf8(runtime) + "\" is not an ArrayBuffer - " "in fact, it's not even an object!"); } +#endif jsi::Object object = arg.asObject(runtime); +#ifdef NITRO_DEBUG if (!object.isArrayBuffer(runtime)) [[unlikely]] { throw std::invalid_argument("Object \"" + arg.toString(runtime).utf8(runtime) + "\" is not an ArrayBuffer! " "Are you maybe passing a TypedArray (e.g. Uint8Array)? Try to pass it's `.buffer` value."); } +#endif JSICacheReference cache = JSICache::getOrCreateCache(runtime); auto borrowingArrayBuffer = cache.makeShared(object.getArrayBuffer(runtime)); diff --git a/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+HostObject.hpp b/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+HostObject.hpp index 1098e6a6e..22cb8a392 100644 --- a/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+HostObject.hpp +++ b/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+HostObject.hpp @@ -20,6 +20,7 @@ struct JSIConverter>> using TPointee = typename T::element_type; static inline T fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { +#ifdef NITRO_DEBUG if (!arg.isObject()) [[unlikely]] { if (arg.isUndefined()) [[unlikely]] { throw jsi::JSError(runtime, invalidTypeErrorMessage("undefined", "It is undefined!")); @@ -28,8 +29,10 @@ struct JSIConverter>> throw jsi::JSError(runtime, invalidTypeErrorMessage(stringRepresentation, "It is not an object!")); } } +#endif jsi::Object object = arg.asObject(runtime); +#ifdef NITRO_DEBUG if (!object.isHostObject(runtime)) [[unlikely]] { if (!object.isHostObject(runtime)) [[unlikely]] { std::string stringRepresentation = arg.toString(runtime).utf8(runtime); @@ -39,6 +42,7 @@ struct JSIConverter>> throw jsi::JSError(runtime, invalidTypeErrorMessage(stringRepresentation, "It is a different HostObject!")); } } +#endif return object.getHostObject(runtime); } diff --git a/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+HybridObject.hpp b/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+HybridObject.hpp index 8720f7d43..b5c190db2 100644 --- a/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+HybridObject.hpp +++ b/packages/react-native-nitro-modules/cpp/jsi/JSIConverter+HybridObject.hpp @@ -25,6 +25,7 @@ struct JSIConverter> using TPointee = typename T::element_type; static inline T fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { +#ifdef NITRO_DEBUG if (!arg.isObject()) [[unlikely]] { if (arg.isUndefined()) [[unlikely]] { throw jsi::JSError(runtime, invalidTypeErrorMessage("undefined", "It is undefined!")); @@ -33,8 +34,10 @@ struct JSIConverter> throw jsi::JSError(runtime, invalidTypeErrorMessage(stringRepresentation, "It is not an object!")); } } +#endif jsi::Object object = arg.asObject(runtime); +#ifdef NITRO_DEBUG if (!object.hasNativeState(runtime)) [[unlikely]] { if (!object.hasNativeState(runtime)) [[unlikely]] { std::string stringRepresentation = arg.toString(runtime).utf8(runtime); @@ -44,6 +47,7 @@ struct JSIConverter> throw jsi::JSError(runtime, invalidTypeErrorMessage(stringRepresentation, "It has a different NativeState!")); } } +#endif std::shared_ptr nativeState = object.getNativeState(runtime); return std::dynamic_pointer_cast(nativeState); } diff --git a/packages/react-native-nitro-modules/cpp/registry/HybridObjectRegistry.cpp b/packages/react-native-nitro-modules/cpp/registry/HybridObjectRegistry.cpp index bd783f36e..fc9397e81 100644 --- a/packages/react-native-nitro-modules/cpp/registry/HybridObjectRegistry.cpp +++ b/packages/react-native-nitro-modules/cpp/registry/HybridObjectRegistry.cpp @@ -32,6 +32,7 @@ std::vector HybridObjectRegistry::getAllHybridObjectNames() { void HybridObjectRegistry::registerHybridObjectConstructor(const std::string& hybridObjectName, HybridObjectConstructorFn&& constructorFn) { Logger::log(LogLevel::Info, TAG, "Registering HybridObject \"%s\"...", hybridObjectName.c_str()); auto& map = HybridObjectRegistry::getRegistry(); +#ifdef NITRO_DEBUG if (map.contains(hybridObjectName)) [[unlikely]] { auto message = "HybridObject \"" + std::string(hybridObjectName) + @@ -41,6 +42,7 @@ void HybridObjectRegistry::registerHybridObjectConstructor(const std::string& hy "- If you just registered your own HybridObject, maybe you accidentally called `registerHybridObjectConstructor(...)` twice?"; throw std::runtime_error(message); } +#endif map.insert({hybridObjectName, std::move(constructorFn)}); Logger::log(LogLevel::Info, TAG, "Successfully registered HybridObject \"%s\"!", hybridObjectName.c_str()); } From 75a0d0a16c51faeb6535cc825e30e792d7fef594 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Tue, 12 Nov 2024 11:22:22 +0100 Subject: [PATCH 3/3] fix: Wtf now it works? --- packages/react-native-nitro-modules/cpp/core/HybridFunction.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/react-native-nitro-modules/cpp/core/HybridFunction.hpp b/packages/react-native-nitro-modules/cpp/core/HybridFunction.hpp index 1f6a36461..f95ff3404 100644 --- a/packages/react-native-nitro-modules/cpp/core/HybridFunction.hpp +++ b/packages/react-native-nitro-modules/cpp/core/HybridFunction.hpp @@ -186,7 +186,6 @@ class HybridFunction final { jsi::Object object = value.getObject(runtime); // 2. Check if it even has any kind of `NativeState` -#ifdef NITRO_DEBUG if (!object.hasNativeState(runtime)) [[unlikely]] { throw jsi::JSError(runtime, "Cannot " + getHybridFuncDebugInfo(funcKind, funcName) + " - `this` does not have a NativeState! Suggestions:\n" @@ -197,7 +196,6 @@ class HybridFunction final { "- Did you accidentally call `" + funcName + "` on the prototype directly?"); } -#endif // 3. Get `NativeState` from the jsi::Object and check if it is non-null std::shared_ptr nativeState = object.getNativeState(runtime);