Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v20.2.0 release proposal #48020

Merged
merged 104 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
d25c785
test: allow SIGBUS in signal-handler abort test
targos May 5, 2023
34bfb69
test: migrate message tests to use assertSnapshot
MoLow Apr 27, 2023
7323902
tools: fix jsdoc lint
MoLow Apr 30, 2023
36f7cfa
tools: update eslint to 8.39.0
nodejs-github-bot Apr 30, 2023
c923367
test: fix WPT state when process exits but workers are still running
panva May 3, 2023
f710676
doc: update BUILDING.md previous versions links
tniessen May 3, 2023
811b43c
doc,test: update the v8.startupSnapshot doc and test the example
joyeecheung May 3, 2023
2952cc5
src: add per-isolate SetFastMethod and Set[Fast]MethodNoSideEffect
joyeecheung Apr 28, 2023
d6d12bf
bootstrap: log isolate data info in mksnapshot debug logs
joyeecheung Apr 28, 2023
a0da234
fs: move fs_use_promises_symbol to per-isolate symbols
joyeecheung Apr 28, 2023
456fca0
bootstrap: initialize per-isolate properties of bindings separately
joyeecheung Apr 28, 2023
b04d51a
src: prefer data accessor of string and vector
VoltrexKeyva May 3, 2023
c092df9
doc: add ovflowd to collaborators
ovflowd May 3, 2023
977fd7c
meta: bump codecov/codecov-action from 3.1.1 to 3.1.3
dependabot[bot] May 3, 2023
9f06eac
meta: bump github/codeql-action from 2.2.9 to 2.3.2
dependabot[bot] May 3, 2023
e53e823
doc: replace EOL versions in README
tniessen May 3, 2023
17945a2
test: migrate a pseudo_tty test to use assertSnapshot
MoLow May 4, 2023
1666a14
doc: add valgrind suppression details
KevinEady May 4, 2023
6f3876c
worker: use snapshot in workers spawned by workers
joyeecheung May 4, 2023
7222f9d
path: indicate index of wrong resolve() parameter
sosoba May 4, 2023
1a7fc18
sea: allow requiring core modules with the "node:" prefix
RaisinTen May 4, 2023
c4596b9
sea: add option to disable the experimental SEA warning
RaisinTen May 4, 2023
d358317
src: get binding data store directly from the realm
joyeecheung Apr 5, 2023
1625ae1
quic: address recent coverity warning
mhdawson May 4, 2023
4bc17fd
src: avoid strcmp() with Utf8Value
tniessen May 4, 2023
c421761
src: fix creating an ArrayBuffer from a Blob created with `openAsBlob`
daeyeon Apr 24, 2023
739113f
module: block requiring `test/reporters` without scheme
MoLow May 5, 2023
54607bf
test: reduce WPT concurrency
panva May 5, 2023
a4d6543
http2: improve nghttp2 error callback
tniessen May 5, 2023
f489c67
node-api: get Node API version used by addon
vmoroz Apr 7, 2023
30f4f35
test: fix output tests when path includes node version
MoLow May 5, 2023
f96fb2e
doc: swap Matteo with Rafael in the stewards
RafaelGSS May 5, 2023
89c70dc
doc: add stability experimental to pm
RafaelGSS May 6, 2023
d23b1af
deps: update ada to 2.3.1
nodejs-github-bot May 6, 2023
9a362aa
doc: update supported version of FreeBSD to 12.4
targos May 6, 2023
93f1aa2
doc: fix params names
Semigradsky May 6, 2023
e9c6ee7
crypto: remove default encoding from pbkdf2
tniessen May 7, 2023
515c9b8
src: clarify the parameter name in `Permission::Apply`
daeyeon May 7, 2023
4dfc389
doc: improve `permission.has` description
daeyeon May 7, 2023
7b2f17c
deps: upgrade npm to 9.6.6
npm-cli-bot May 7, 2023
7e34f77
test: fix webcrypto wrap unwrap tests
panva May 7, 2023
09fb74a
crypto: fix webcrypto private/secret import with empty usages
panva May 7, 2023
8f547af
test: use appropriate usages for a negative import test
panva May 7, 2023
652b06d
meta: remove extra space in scorecard workflow
Mesteery May 1, 2023
0f58e48
meta: bump actions/checkout from 3.3.0 to 3.5.2
dependabot[bot] May 1, 2023
f7a8094
meta: bump actions/setup-python from 4.5.0 to 4.6.0
dependabot[bot] May 7, 2023
6c158e8
meta: bump step-security/harden-runner from 2.2.1 to 2.3.1
dependabot[bot] May 7, 2023
cad42e7
deps: V8: cherry-pick 1b471b796022
luyahan May 7, 2023
a11507e
src: stop copying code cache
kvakil May 7, 2023
1b06c1e
url: improve `isURL` detection
anonrig May 7, 2023
e457d89
buffer: combine checking range of sourceStart in `buf.copy`
deokjinkim May 7, 2023
72340c9
dgram: convert macro to template
tniessen May 8, 2023
9bc5d78
src: register ext reference for Fingerprint512
tniessen May 8, 2023
00668fc
child_process: use signal.reason in child process abort
debadree25 May 8, 2023
c19385c
module: refactor to use `normalizeRequirableId` in the CJS module loader
RaisinTen May 8, 2023
e22c686
tools: update eslint to 8.40.0
nodejs-github-bot May 9, 2023
4293cc4
src: support V8 experimental shared values in messaging
syg May 9, 2023
bf39f2d
doc: ntfs junction points must link to directories
bnoordhuis May 9, 2023
706c305
tools: update lint-md-dependencies to rollup@3.21.5
nodejs-github-bot May 9, 2023
c2b14b4
deps: update ada to 2.4.0
nodejs-github-bot May 9, 2023
7ed99e8
doc: mark global object as legacy
mertcanaltin May 9, 2023
f6ff318
tools: automate icu-small update
marco-ippolito May 9, 2023
c9ffc55
doc: document make lint-md-clean
mcollina May 10, 2023
106dc61
fs: make readdir recursive algorithm iterative
May 10, 2023
190596c
src: register external references for source code
kvakil May 10, 2023
99f8fca
deps: V8: cherry-pick a8a11a87cb72
targos Apr 18, 2023
b16f6da
deps: V8: cherry-pick 5f025d1ca2ca
targos Apr 18, 2023
bd553e7
src: rename SKIP_CHECK_SIZE to SKIP_CHECK_STRLEN
tniessen May 10, 2023
d81c54e
test_runner: omit inaccessible files from coverage
cjihrig May 10, 2023
9be9228
dns: call `ada::idna::to_ascii` directly from c++
anonrig May 10, 2023
aa2c7e0
test,crypto: update WebCryptoAPI WPT
panva May 10, 2023
42db1d5
test_runner: fix ordering of test hooks
philnash May 11, 2023
0c06bfd
src: move BlobSerializerDeserializer to a separate header file
RaisinTen May 9, 2023
af86625
permission: resolve reference to absolute path only for fs permission
daeyeon May 11, 2023
2a3d6d9
meta: add security-wg ping to permission.js
RafaelGSS May 11, 2023
6f5ba92
doc: remove broken link
Trott May 11, 2023
d799347
crypto: remove default encoding from scrypt
tniessen May 12, 2023
6e01958
test: unskip negative-settimeout.any.js WPT
panva May 12, 2023
a4fed6c
lib: update comment
sinkhaha May 5, 2023
47fea13
worker: support more cases when (de)serializing errors
MoLow May 12, 2023
b9771c9
doc: fix broken link
Trott May 12, 2023
bb33c74
test: add getRandomValues return length
MrJithil May 13, 2023
7ecc674
doc: fix broken link to TC39 import attributes proposal
Trott May 13, 2023
e6685f9
vm,lib: refactor microtaskQueue assignment logic
XadillaX Apr 28, 2023
4197a9a
http: prevent writing to the body when not allowed by HTTP spec
gerrard00 May 13, 2023
3727964
doc: update measure memory rejection information
yashLadha May 13, 2023
c05c0a2
meta: bump actions/setup-python from 4.5.0 to 4.6.0
Trott May 13, 2023
13118a1
doc: update description of global
tniessen May 13, 2023
1ec640a
esm: do not use `'beforeExit'` on the main thread
aduh95 May 14, 2023
1aec718
src: add cjs_module_lexer_version base64_version
MrJithil May 14, 2023
a0634d7
url: add value argument to has and delete methods
sankalp1999 May 14, 2023
a4e261e
tools: debug log for nghttp3
marco-ippolito May 14, 2023
f5b4b6d
meta: bump github/codeql-action from 2.3.2 to 2.3.3
Trott May 14, 2023
fd8bec7
meta: bump step-security/harden-runner from 2.3.1 to 2.4.0
Trott May 14, 2023
4a1e971
doc: add missing deprecated blocks to cluster
tniessen May 14, 2023
b7f13a8
deps: update simdutf to 3.2.9
nodejs-github-bot May 14, 2023
060c1d5
src: stop copying code cache, part 2
kvakil May 15, 2023
17befe0
test_runner: add shorthands to `test`
atlowChemi May 15, 2023
2bd869d
vm: fix crash when setting __proto__ on context's globalThis
F3n67u May 15, 2023
010d2ec
test: mark test-esm-loader-http-imports as flaky
tniessen May 15, 2023
786a1c5
src: deduplicate X509Certificate::Fingerprint*
tniessen May 15, 2023
7dd32f1
permission: remove unused function declaration
deokjinkim May 15, 2023
da27542
test_runner: use v8.serialize instead of TAP
MoLow May 15, 2023
258e9e7
2023-05-16, Version 20.2.0 (Current)
targos May 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
node-api: get Node API version used by addon
PR-URL: #45715
Reviewed-By: Gabriel Schulhof <gabrielschulhof@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
  • Loading branch information
vmoroz authored and targos committed May 12, 2023
commit f489c6710c31e83fec6f57db5c9feaec45d605f4
61 changes: 38 additions & 23 deletions doc/api/n-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1639,25 +1639,36 @@ If it is called more than once an error will be returned.

This API can be called even if there is a pending JavaScript exception.

### References to objects with a lifespan longer than that of the native method
### References to values with a lifespan longer than that of the native method

In some cases an addon will need to be able to create and reference objects
In some cases, an addon will need to be able to create and reference values
with a lifespan longer than that of a single native method invocation. For
example, to create a constructor and later use that constructor
in a request to creates instances, it must be possible to reference
in a request to create instances, it must be possible to reference
the constructor object across many different instance creation requests. This
would not be possible with a normal handle returned as a `napi_value` as
described in the earlier section. The lifespan of a normal handle is
managed by scopes and all scopes must be closed before the end of a native
method.

Node-API provides methods to create persistent references to an object.
Each persistent reference has an associated count with a value of 0
or higher. The count determines if the reference will keep
the corresponding object live. References with a count of 0 do not
prevent the object from being collected and are often called 'weak'
references. Any count greater than 0 will prevent the object
from being collected.
Node-API provides methods for creating persistent references to values.
Each reference has an associated count with a value of 0 or higher,
which determines whether the reference will keep the corresponding value alive.
References with a count of 0 do not prevent values from being collected.
Values of object (object, function, external) and symbol types are becoming
'weak' references and can still be accessed while they are not collected.
Values of other types are released when the count becomes 0
and cannot be accessed from the reference any more.
Any count greater than 0 will prevent the values from being collected.

Symbol values have different flavors. The true weak reference behavior is
only supported by local symbols created with the `Symbol()` constructor call.
Globally registered symbols created with the `Symbol.for()` call remain
always strong references because the garbage collector does not collect them.
The same is true for well-known symbols such as `Symbol.iterator`. They are
also never collected by the garbage collector. JavaScript's `WeakRef` and
`WeakMap` types return an error when registered symbols are used,
but they succeed for local and well-known symbols.

References can be created with an initial reference count. The count can
then be modified through [`napi_reference_ref`][] and
Expand All @@ -1668,6 +1679,11 @@ will return `NULL` for the returned `napi_value`. An attempt to call
[`napi_reference_ref`][] for a reference whose object has been collected
results in an error.

Node-API versions 8 and earlier only allow references to be created for a
limited set of value types, including object, external, function, and symbol.
However, in newer Node-API versions, references can be created for any
value type.

References must be deleted once they are no longer required by the addon. When
a reference is deleted, it will no longer prevent the corresponding object from
being collected. Failure to delete a persistent reference results in
Expand Down Expand Up @@ -1700,15 +1716,18 @@ NAPI_EXTERN napi_status napi_create_reference(napi_env env,
```

* `[in] env`: The environment that the API is invoked under.
* `[in] value`: `napi_value` representing the `Object` to which we want a
reference.
* `[in] value`: The `napi_value` for which a reference is being created.
* `[in] initial_refcount`: Initial reference count for the new reference.
* `[out] result`: `napi_ref` pointing to the new reference.

Returns `napi_ok` if the API succeeded.

This API creates a new reference with the specified reference count
to the `Object` passed in.
to the value passed in.

In Node-API version 8 and earlier, a reference could only be created for
object, function, external, and symbol value types. However, in newer Node-API
versions, a reference can be created for any value type.

#### `napi_delete_reference`

Expand Down Expand Up @@ -1787,18 +1806,15 @@ NAPI_EXTERN napi_status napi_get_reference_value(napi_env env,
napi_value* result);
```

the `napi_value passed` in or out of these methods is a handle to the
object to which the reference is related.

* `[in] env`: The environment that the API is invoked under.
* `[in] ref`: `napi_ref` for which we requesting the corresponding `Object`.
* `[out] result`: The `napi_value` for the `Object` referenced by the
`napi_ref`.
* `[in] ref`: The `napi_ref` for which the corresponding value is
being requested.
* `[out] result`: The `napi_value` referenced by the `napi_ref`.

Returns `napi_ok` if the API succeeded.

If still valid, this API returns the `napi_value` representing the
JavaScript `Object` associated with the `napi_ref`. Otherwise, result
JavaScript value associated with the `napi_ref`. Otherwise, result
will be `NULL`.

### Cleanup on exit of the current Node.js environment
Expand Down Expand Up @@ -5069,9 +5085,8 @@ napi_status napi_define_class(napi_env env,
```

* `[in] env`: The environment that the API is invoked under.
* `[in] utf8name`: Name of the JavaScript constructor function; When wrapping a
C++ class, we recommend for clarity that this name be the same as that of
the C++ class.
* `[in] utf8name`: Name of the JavaScript constructor function. For clarity,
it is recommended to use the C++ class name when wrapping a C++ class.
* `[in] length`: The length of the `utf8name` in bytes, or `NAPI_AUTO_LENGTH`
if it is null-terminated.
* `[in] constructor`: Callback function that handles constructing instances
Expand Down
30 changes: 11 additions & 19 deletions src/api/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -872,26 +872,18 @@ void AddLinkedBinding(Environment* env,

void AddLinkedBinding(Environment* env,
const char* name,
napi_addon_register_func fn) {
napi_addon_register_func fn,
int32_t module_api_version) {
node_module mod = {
-1,
NM_F_LINKED,
nullptr, // nm_dso_handle
nullptr, // nm_filename
nullptr, // nm_register_func
[](v8::Local<v8::Object> exports,
v8::Local<v8::Value> module,
v8::Local<v8::Context> context,
void* priv) {
napi_module_register_by_symbol(
exports,
module,
context,
reinterpret_cast<napi_addon_register_func>(priv));
},
name,
reinterpret_cast<void*>(fn),
nullptr // nm_link
-1, // nm_version for Node-API
NM_F_LINKED, // nm_flags
nullptr, // nm_dso_handle
nullptr, // nm_filename
nullptr, // nm_register_func
get_node_api_context_register_func(env, name, module_api_version),
name, // nm_modname
reinterpret_cast<void*>(fn), // nm_priv
nullptr // nm_link
};
AddLinkedBinding(env, mod);
}
Expand Down
31 changes: 25 additions & 6 deletions src/js_native_api_v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,18 @@ inline napi_status Wrap(napi_env env,
return GET_RETURN_STATUS(env);
}

// In JavaScript, weak references can be created for object types (Object,
// Function, and external Object) and for local symbols that are created with
// the `Symbol` function call. Global symbols created with the `Symbol.for`
// method cannot be weak references because they are never collected.
//
// Currently, V8 has no API to detect if a symbol is local or global.
// Until we have a V8 API for it, we consider that all symbols can be weak.
// This matches the current Node-API behavior.
inline bool CanBeHeldWeakly(v8::Local<v8::Value> value) {
return value->IsObject() || value->IsSymbol();
}

} // end of anonymous namespace

void Finalizer::ResetFinalizer() {
Expand Down Expand Up @@ -551,7 +563,8 @@ void RefBase::Finalize() {
template <typename... Args>
Reference::Reference(napi_env env, v8::Local<v8::Value> value, Args&&... args)
: RefBase(env, std::forward<Args>(args)...),
persistent_(env->isolate, value) {
persistent_(env->isolate, value),
can_be_weak_(CanBeHeldWeakly(value)) {
if (RefCount() == 0) {
SetWeak();
}
Expand Down Expand Up @@ -585,7 +598,7 @@ uint32_t Reference::Ref() {
return 0;
}
uint32_t refcount = RefBase::Ref();
if (refcount == 1) {
if (refcount == 1 && can_be_weak_) {
persistent_.ClearWeak();
}
return refcount;
Expand Down Expand Up @@ -625,7 +638,11 @@ void Reference::Finalize() {
// Mark the reference as weak and eligible for collection
// by the gc.
void Reference::SetWeak() {
persistent_.SetWeak(this, WeakCallback, v8::WeakCallbackType::kParameter);
if (can_be_weak_) {
persistent_.SetWeak(this, WeakCallback, v8::WeakCallbackType::kParameter);
} else {
persistent_.Reset();
}
}

// The N-API finalizer callback may make calls into the engine. V8's heap is
Expand Down Expand Up @@ -2419,9 +2436,11 @@ napi_status NAPI_CDECL napi_create_reference(napi_env env,
CHECK_ARG(env, result);

v8::Local<v8::Value> v8_value = v8impl::V8LocalValueFromJsValue(value);
if (!(v8_value->IsObject() || v8_value->IsFunction() ||
v8_value->IsSymbol())) {
return napi_set_last_error(env, napi_invalid_arg);
if (env->module_api_version <= 8) {
if (!(v8_value->IsObject() || v8_value->IsFunction() ||
v8_value->IsSymbol())) {
return napi_set_last_error(env, napi_invalid_arg);
}
}

v8impl::Reference* reference = v8impl::Reference::New(
Expand Down
9 changes: 7 additions & 2 deletions src/js_native_api_v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ class Finalizer;
} // end of namespace v8impl

struct napi_env__ {
explicit napi_env__(v8::Local<v8::Context> context)
: isolate(context->GetIsolate()), context_persistent(isolate, context) {
explicit napi_env__(v8::Local<v8::Context> context,
int32_t module_api_version)
: isolate(context->GetIsolate()),
context_persistent(isolate, context),
module_api_version(module_api_version) {
napi_clear_last_error(this);
}

Expand Down Expand Up @@ -144,6 +147,7 @@ struct napi_env__ {
int open_callback_scopes = 0;
int refs = 1;
void* instance_data = nullptr;
int32_t module_api_version = NODE_API_DEFAULT_MODULE_API_VERSION;

protected:
// Should not be deleted directly. Delete with `napi_env__::DeleteMe()`
Expand Down Expand Up @@ -419,6 +423,7 @@ class Reference : public RefBase {
void SetWeak();

v8impl::Persistent<v8::Value> persistent_;
bool can_be_weak_;
};

} // end of namespace v8impl
Expand Down
8 changes: 5 additions & 3 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -1237,9 +1237,11 @@ NODE_EXTERN void AddLinkedBinding(Environment* env,
const char* name,
addon_context_register_func fn,
void* priv);
NODE_EXTERN void AddLinkedBinding(Environment* env,
const char* name,
napi_addon_register_func fn);
NODE_EXTERN void AddLinkedBinding(
Environment* env,
const char* name,
napi_addon_register_func fn,
int32_t module_api_version = NODE_API_DEFAULT_MODULE_API_VERSION);

/* Registers a callback with the passed-in Environment instance. The callback
* is called after the event loop exits, but before the VM is disposed.
Expand Down
76 changes: 70 additions & 6 deletions src/node_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
#include <memory>

node_napi_env__::node_napi_env__(v8::Local<v8::Context> context,
const std::string& module_filename)
: napi_env__(context), filename(module_filename) {
const std::string& module_filename,
int32_t module_api_version)
: napi_env__(context, module_api_version), filename(module_filename) {
CHECK_NOT_NULL(node_env());
}

Expand Down Expand Up @@ -151,11 +152,36 @@ class BufferFinalizer : private Finalizer {
~BufferFinalizer() { env_->Unref(); }
};

void ThrowNodeApiVersionError(node::Environment* node_env,
const char* module_name,
int32_t module_api_version) {
std::string error_message;
error_message += module_name;
error_message += " requires Node-API version ";
error_message += std::to_string(module_api_version);
error_message += ", but this version of Node.js only supports version ";
error_message += NODE_STRINGIFY(NAPI_VERSION) " add-ons.";
node_env->ThrowError(error_message.c_str());
}

inline napi_env NewEnv(v8::Local<v8::Context> context,
const std::string& module_filename) {
const std::string& module_filename,
int32_t module_api_version) {
node_napi_env result;

result = new node_napi_env__(context, module_filename);
// Validate module_api_version.
if (module_api_version < NODE_API_DEFAULT_MODULE_API_VERSION) {
module_api_version = NODE_API_DEFAULT_MODULE_API_VERSION;
} else if (module_api_version > NAPI_VERSION &&
module_api_version != NAPI_VERSION_EXPERIMENTAL) {
node::Environment* node_env = node::Environment::GetCurrent(context);
CHECK_NOT_NULL(node_env);
ThrowNodeApiVersionError(
node_env, module_filename.c_str(), module_api_version);
return nullptr;
}

result = new node_napi_env__(context, module_filename, module_api_version);
// TODO(addaleax): There was previously code that tried to delete the
// napi_env when its v8::Context was garbage collected;
// However, as long as N-API addons using this napi_env are in place,
Expand Down Expand Up @@ -623,10 +649,48 @@ static void napi_module_register_cb(v8::Local<v8::Object> exports,
static_cast<const napi_module*>(priv)->nm_register_func);
}

template <int32_t module_api_version>
static void node_api_context_register_func(v8::Local<v8::Object> exports,
v8::Local<v8::Value> module,
v8::Local<v8::Context> context,
void* priv) {
napi_module_register_by_symbol(
exports,
module,
context,
reinterpret_cast<napi_addon_register_func>(priv),
module_api_version);
}

// This function must be augmented for each new Node API version.
// The key role of this function is to encode module_api_version in the function
// pointer. We are not going to have many Node API versions and having one
// function per version is relatively cheap. It avoids dynamic memory
// allocations or implementing more expensive changes to module registration.
// Currently AddLinkedBinding is the only user of this function.
node::addon_context_register_func get_node_api_context_register_func(
node::Environment* node_env,
const char* module_name,
int32_t module_api_version) {
static_assert(
NAPI_VERSION == 8,
"New version of Node-API requires adding another else-if statement below "
"for the new version and updating this assert condition.");
if (module_api_version <= NODE_API_DEFAULT_MODULE_API_VERSION) {
return node_api_context_register_func<NODE_API_DEFAULT_MODULE_API_VERSION>;
} else if (module_api_version == NAPI_VERSION_EXPERIMENTAL) {
return node_api_context_register_func<NAPI_VERSION_EXPERIMENTAL>;
} else {
v8impl::ThrowNodeApiVersionError(node_env, module_name, module_api_version);
return nullptr;
}
}

void napi_module_register_by_symbol(v8::Local<v8::Object> exports,
v8::Local<v8::Value> module,
v8::Local<v8::Context> context,
napi_addon_register_func init) {
napi_addon_register_func init,
int32_t module_api_version) {
node::Environment* node_env = node::Environment::GetCurrent(context);
std::string module_filename = "";
if (init == nullptr) {
Expand Down Expand Up @@ -654,7 +718,7 @@ void napi_module_register_by_symbol(v8::Local<v8::Object> exports,
}

// Create a new napi_env for this specific module.
napi_env env = v8impl::NewEnv(context, module_filename);
napi_env env = v8impl::NewEnv(context, module_filename, module_api_version);

napi_value _exports = nullptr;
env->CallIntoModule([&](napi_env env) {
Expand Down
Loading