Skip to content

Commit fc0a1a0

Browse files
author
Mariusz Pasinski
committed
fix: assertion firing when loading deprecated way
1 parent e8ff65d commit fc0a1a0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/host/cpp/AddonRegistry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ bool AddonRegistry::tryLoadAddonAsDynamicLib(NodeAddon &addon, const std::string
102102
// Load addon as dynamic library
103103
typename LoaderPolicy::Module library = LoaderPolicy::loadLibrary(path.c_str());
104104
if (nullptr != library) {
105+
addon.moduleApiVersion_ = NODE_API_DEFAULT_MODULE_API_VERSION;
105106
if (nullptr != pendingRegistration_) {
106107
// there is a pending addon that used the deprecated `napi_register_module()`
107108
addon.initFun_ = pendingRegistration_;
@@ -110,7 +111,6 @@ bool AddonRegistry::tryLoadAddonAsDynamicLib(NodeAddon &addon, const std::string
110111
typename LoaderPolicy::Symbol initFn = LoaderPolicy::getSymbol(library, "napi_register_module_v1");
111112
if (nullptr != initFn) {
112113
addon.initFun_ = (napi_addon_register_func)initFn;
113-
addon.moduleApiVersion_ = NODE_API_DEFAULT_MODULE_API_VERSION;
114114
// This solves https://github.com/callstackincubator/react-native-node-api-modules/issues/4
115115
typename LoaderPolicy::Symbol getVersionFn = LoaderPolicy::getSymbol(library, "node_api_module_get_api_version_v1");
116116
if (nullptr != getVersionFn) {

0 commit comments

Comments
 (0)