8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 526e78f commit cd3a8e8Copy full SHA for cd3a8e8
doc/api/cli.md
@@ -178,14 +178,6 @@ added: v8.4.0
178
179
Enable the experimental `'http2'` module.
180
181
-### `--napi-modules`
182
-<!-- YAML
183
-added: v8.0.0
184
--->
185
-
186
-Enable loading native modules compiled with the ABI-stable Node.js API (N-API)
187
-(experimental).
188
189
### `--abort-on-uncaught-exception`
190
<!-- YAML
191
added: v0.10
@@ -453,7 +445,6 @@ Node options that are allowed are:
453
445
- `--inspect-brk`
454
446
- `--inspect-port`
455
447
- `--inspect`
456
-- `--napi-modules`
457
448
- `--no-deprecation`
458
449
- `--no-warnings`
459
450
- `--openssl-config`
doc/api/n-api.md
@@ -63,14 +63,6 @@ For example:
63
#include <node_api.h>
64
```
65
66
-As the feature is experimental it must be enabled with the
67
-following command line
68
-[option](https://nodejs.org/dist/latest-v8.x/docs/api/cli.html#cli_napi_modules):
69
70
-```bash
71
---napi-modules
72
-```
73
74
## Basic N-API Data Types
75
76
N-API exposes the following fundamental datatypes as abstractions that are
src/env-inl.h
@@ -288,6 +288,7 @@ inline Environment::Environment(IsolateData* isolate_data,
288
printed_error_(false),
289
trace_sync_io_(false),
290
abort_on_uncaught_exception_(false),
291
+ emit_napi_warning_(true),
292
makecallback_cntr_(0),
293
#if HAVE_INSPECTOR
294
inspector_agent_(this),
src/env.cc
@@ -213,6 +213,12 @@ bool Environment::RemovePromiseHook(promise_hook_func fn, void* arg) {
213
return true;
214
}
215
216
+bool Environment::EmitNapiWarning() {
217
+ bool current_value = emit_napi_warning_;
218
+ emit_napi_warning_ = false;
219
+ return current_value;
220
+}
221
+
222
void Environment::EnvPromiseHook(v8::PromiseHookType type,
223
v8::Local<v8::Promise> promise,
224
v8::Local<v8::Value> parent) {
src/env.h
@@ -669,6 +669,7 @@ class Environment {
669
670
void AddPromiseHook(promise_hook_func fn, void* arg);
671
bool RemovePromiseHook(promise_hook_func fn, void* arg);
672
+ bool EmitNapiWarning();
673
674
private:
675
inline void ThrowError(v8::Local<v8::Value> (*fun)(v8::Local<v8::String>),
@@ -690,6 +691,7 @@ class Environment {
690
691
bool printed_error_;
692
bool trace_sync_io_;
693
bool abort_on_uncaught_exception_;
694
+ bool emit_napi_warning_;
695
size_t makecallback_cntr_;
696
std::vector<double> destroy_ids_list_;
697
src/node.cc
@@ -193,9 +193,6 @@ unsigned int reverted = 0;
193
std::string icu_data_dir; // NOLINT(runtime/string)
194
#endif
195
196
-// N-API is in experimental state, disabled by default.
197
-bool load_napi_modules = false;
198
199
// used by C++ modules as well
200
bool no_deprecation = false;
201
@@ -2650,27 +2647,22 @@ static void DLOpen(const FunctionCallbackInfo<Value>& args) {
2650
2647
env->ThrowError("Module did not self-register.");
2651
2648
return;
2652
2649
2653
- if (mp->nm_version != NODE_MODULE_VERSION) {
2654
- char errmsg[1024];
2655
- if (mp->nm_version == -1) {
2656
- snprintf(errmsg,
2657
- sizeof(errmsg),
2658
- "The module '%s'"
2659
- "\nwas compiled against the ABI-stable Node.js API (N-API)."
2660
- "\nThis feature is experimental and must be enabled on the "
2661
- "\ncommand-line by adding --napi-modules.",
2662
- *filename);
2663
- } else {
2664
2665
2666
2667
- "\nwas compiled against a different Node.js version using"
2668
- "\nNODE_MODULE_VERSION %d. This version of Node.js requires"
2669
- "\nNODE_MODULE_VERSION %d. Please try re-compiling or "
2670
- "re-installing\nthe module (for instance, using `npm rebuild` "
2671
- "or `npm install`).",
2672
- *filename, mp->nm_version, NODE_MODULE_VERSION);
+ if (mp->nm_version == -1) {
+ if (env->EmitNapiWarning()) {
+ ProcessEmitWarning(env, "N-API is an experimental feature and could "
+ "change at any time.");
2673
+ } else if (mp->nm_version != NODE_MODULE_VERSION) {
+ char errmsg[1024];
+ snprintf(errmsg,
+ sizeof(errmsg),
+ "The module '%s'"
+ "\nwas compiled against a different Node.js version using"
+ "\nNODE_MODULE_VERSION %d. This version of Node.js requires"
+ "\nNODE_MODULE_VERSION %d. Please try re-compiling or "
+ "re-installing\nthe module (for instance, using `npm rebuild` "
+ "or `npm install`).",
+ *filename, mp->nm_version, NODE_MODULE_VERSION);
2674
2675
// NOTE: `mp` is allocated inside of the shared library's memory, calling
2676
// `uv_dlclose` will deallocate it
@@ -3769,7 +3761,8 @@ static void PrintHelp() {
3769
3761
" --throw-deprecation throw an exception on deprecations\n"
3770
3762
" --pending-deprecation emit pending deprecation warnings\n"
3771
3763
" --no-warnings silence all process warnings\n"
3772
- " --napi-modules load N-API modules\n"
3764
+ " --napi-modules load N-API modules (no-op - option\n"
3765
+ " kept for compatibility)\n"
3773
3766
" --abort-on-uncaught-exception\n"
3774
3767
" aborting instead of exiting causes a\n"
3775
3768
" core file to be generated for analysis\n"
@@ -4027,7 +4020,7 @@ static void ParseArgs(int* argc,
4027
4020
} else if (strcmp(arg, "--no-deprecation") == 0) {
4028
4021
no_deprecation = true;
4029
4022
} else if (strcmp(arg, "--napi-modules") == 0) {
4030
- load_napi_modules = true;
4023
+ // no-op
4031
4024
} else if (strcmp(arg, "--no-warnings") == 0) {
4032
4025
no_process_warnings = true;
4033
4026
} else if (strcmp(arg, "--trace-warnings") == 0) {
@@ -4665,11 +4658,6 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data,
4665
4658
4666
4659
env.set_trace_sync_io(trace_sync_io);
4667
4660
4668
- if (load_napi_modules) {
4669
- ProcessEmitWarning(&env, "N-API is an experimental feature "
4670
- "and could change at any time.");
4671
- }
4672
4673
4661
{
4674
4662
SealHandleScope seal(isolate);
4675
4663
bool more;
src/node_api.cc
@@ -841,28 +841,10 @@ void napi_module_register_cb(v8::Local<v8::Object> exports,
841
842
} // end of anonymous namespace
843
844
-#ifndef EXTERNAL_NAPI
845
-namespace node {
846
- // Indicates whether NAPI was enabled/disabled via the node command-line.
847
- extern bool load_napi_modules;
848
-}
849
-#endif // EXTERNAL_NAPI
850
851
// Registers a NAPI module.
852
void napi_module_register(napi_module* mod) {
853
- // NAPI modules always work with the current node version.
854
- int module_version = NODE_MODULE_VERSION;
855
856
857
- if (!node::load_napi_modules) {
858
- // NAPI is disabled, so set the module version to -1 to cause the module
859
- // to be unloaded.
860
- module_version = -1;
861
862
863
864
node::node_module* nm = new node::node_module {
865
- module_version,
+ -1,
866
mod->nm_flags,
867
nullptr,
868
mod->nm_filename,
test/addons-napi/test_async/test.js
@@ -15,7 +15,7 @@ if (process.argv[2] === 'child') {
15
16
17
const p = child_process.spawnSync(
18
- process.execPath, [ '--napi-modules', __filename, 'child' ]);
+ process.execPath, [ __filename, 'child' ]);
19
assert.ifError(p.error);
20
assert.ok(p.stderr.toString().includes(testException));
21
test/addons-napi/test_fatal/test.js
@@ -12,7 +12,7 @@ if (process.argv[2] === 'child') {
12
13
14
assert.ok(p.stderr.toString().includes(
'FATAL ERROR: test_fatal::Test fatal message'));
test/addons-napi/test_function/test_function.c
@@ -26,7 +26,9 @@ napi_value TestCallFunction(napi_env env, napi_callback_info info) {
26
return result;
27
28
29
-void TestFunctionName(napi_env env, napi_callback_info info) {}
+napi_value TestFunctionName(napi_env env, napi_callback_info info) {
30
+ return NULL;
31
32
33
napi_value Init(napi_env env, napi_value exports) {
34
napi_value fn1;