From bb243f013934a4c8eaa496c69173a7ea027b1091 Mon Sep 17 00:00:00 2001 From: Evan Lucas Date: Tue, 11 Oct 2016 18:18:15 -0500 Subject: [PATCH 1/2] process: add emitExperimentalWarning() This adds process.emitExperimentalWarning() which can used to communicate to our users that a feature they are using is experimental and can be changed/removed at any time. Ref: https://github.com/nodejs/node/issues/9036 --- lib/internal/process/warning.js | 10 ++++++++++ test/parallel/test-process-emit-experimentalwarning.js | 9 +++++++++ 2 files changed, 19 insertions(+) create mode 100644 test/parallel/test-process-emit-experimentalwarning.js diff --git a/lib/internal/process/warning.js b/lib/internal/process/warning.js index 74a74aa916dd91..c1839f454460cd 100644 --- a/lib/internal/process/warning.js +++ b/lib/internal/process/warning.js @@ -4,6 +4,8 @@ const prefix = `(${process.release.name}:${process.pid}) `; exports.setup = setupProcessWarnings; +const experimentalWarnings = new Set(); + function setupProcessWarnings() { if (!process.noProcessWarnings) { process.on('warning', (warning) => { @@ -46,4 +48,12 @@ function setupProcessWarnings() { } process.nextTick(() => process.emit('warning', warning)); }; + + process.emitExperimentalWarning = function(feature) { + if (experimentalWarnings.has(feature)) return; + experimentalWarnings.add(feature); + const msg = `${feature} is an experimental feature. ` + + 'This feature could change at any time.'; + process.emitWarning(msg, 'ExperimentalWarning'); + }; } diff --git a/test/parallel/test-process-emit-experimentalwarning.js b/test/parallel/test-process-emit-experimentalwarning.js new file mode 100644 index 00000000000000..7a28fefc04dfe7 --- /dev/null +++ b/test/parallel/test-process-emit-experimentalwarning.js @@ -0,0 +1,9 @@ +'use strict'; + +const common = require('../common'); + +const warning = 'new_feature is an experimental feature. This feature could ' + + 'change at any time.'; +common.expectWarning('ExperimentalWarning', warning); +process.emitExperimentalWarning('new_feature'); +process.emitExperimentalWarning('new_feature'); From 0322d548d19d63edb2fae5b8bd743e056f921caa Mon Sep 17 00:00:00 2001 From: Evan Lucas Date: Mon, 31 Oct 2016 05:06:00 -0500 Subject: [PATCH 2/2] internal: emit experimental warning when using --inspect This is currently an experimental feature, so we should make sure users are aware that it can be changed at any time. Ref: https://github.com/nodejs/node/issues/9036 --- lib/internal/bootstrap_node.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/internal/bootstrap_node.js b/lib/internal/bootstrap_node.js index 8b8d066ab039e9..07b33a9f56787c 100644 --- a/lib/internal/bootstrap_node.js +++ b/lib/internal/bootstrap_node.js @@ -50,6 +50,11 @@ _process.setupRawDebug(); + // TODO(evanlucas) Remove this when v8_inspector is no longer experimental. + if (process.execArgv.indexOf('--inspect') !== -1) { + process.nextTick(() => process.emitExperimentalWarning('v8_inspector')); + } + Object.defineProperty(process, 'argv0', { enumerable: true, configurable: false,