Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions lib/internal/bootstrap_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions lib/internal/process/warning.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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');
};
}
9 changes: 9 additions & 0 deletions test/parallel/test-process-emit-experimentalwarning.js
Original file line number Diff line number Diff line change
@@ -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');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why twice here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to make sure it is only emitted once