summaryrefslogtreecommitdiff
path: root/lib/internal
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-01-21 15:03:20 +0100
committerAnna Henningsen <anna@addaleax.net>2019-01-24 20:36:31 +0100
commit3260a4aa87004ea39fca3f3d56bbe2f7b90dd662 (patch)
tree50a929c5477410aeeb2d98fd27ee50f912d3cfab /lib/internal
parentf4697ba718bed0fcd1a1cebbe1a5dbe8f4893ebf (diff)
downloadandroid-node-v8-3260a4aa87004ea39fca3f3d56bbe2f7b90dd662.tar.gz
android-node-v8-3260a4aa87004ea39fca3f3d56bbe2f7b90dd662.tar.bz2
android-node-v8-3260a4aa87004ea39fca3f3d56bbe2f7b90dd662.zip
report: remove `internalBinding('config').hasReport`
The `setup()` method is only called when the `--experimental-report` option is set. `getOptionValue()` returns `undefined` when the flag is not defined, so the extra check inside of `setup()` is redundant. PR-URL: https://github.com/nodejs/node/pull/25610 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Diffstat (limited to 'lib/internal')
-rw-r--r--lib/internal/process/report.js265
1 files changed, 132 insertions, 133 deletions
diff --git a/lib/internal/process/report.js b/lib/internal/process/report.js
index 2d0d3f3921..9b66526ce3 100644
--- a/lib/internal/process/report.js
+++ b/lib/internal/process/report.js
@@ -11,153 +11,152 @@ exports.setup = function() {
const REPORTFILENAME = 3;
const REPORTPATH = 4;
const REPORTVERBOSE = 5;
- if (internalBinding('config').hasReport) {
- // If report is enabled, extract the binding and
- // wrap the APIs with thin layers, with some error checks.
- // user options can come in from CLI / ENV / API.
- // CLI and ENV is intercepted in C++ and the API call here (JS).
- // So sync up with both sides as appropriate - initially from
- // C++ to JS and from JS to C++ whenever the API is called.
- // Some events are controlled purely from JS (signal | exception)
- // and some from C++ (fatalerror) so this sync-up is essential for
- // correct behavior and alignment with the supplied tunables.
- const nr = internalBinding('report');
- // Keep it un-exposed; lest programs play with it
- // leaving us with a lot of unwanted sanity checks.
- let config = {
- events: [],
- signal: 'SIGUSR2',
- filename: '',
- path: '',
- verbose: false
- };
- const report = {
- setDiagnosticReportOptions(options) {
- emitExperimentalWarning('report');
- // Reuse the null and undefined checks. Save
- // space when dealing with large number of arguments.
- const list = parseOptions(options);
+ // If report is enabled, extract the binding and
+ // wrap the APIs with thin layers, with some error checks.
+ // user options can come in from CLI / ENV / API.
+ // CLI and ENV is intercepted in C++ and the API call here (JS).
+ // So sync up with both sides as appropriate - initially from
+ // C++ to JS and from JS to C++ whenever the API is called.
+ // Some events are controlled purely from JS (signal | exception)
+ // and some from C++ (fatalerror) so this sync-up is essential for
+ // correct behavior and alignment with the supplied tunables.
+ const nr = internalBinding('report');
- // Flush the stale entries from report, as
- // we are refreshing it, items that the users did not
- // touch may be hanging around stale otherwise.
- config = {};
+ // Keep it un-exposed; lest programs play with it
+ // leaving us with a lot of unwanted sanity checks.
+ let config = {
+ events: [],
+ signal: 'SIGUSR2',
+ filename: '',
+ path: '',
+ verbose: false
+ };
+ const report = {
+ setDiagnosticReportOptions(options) {
+ emitExperimentalWarning('report');
+ // Reuse the null and undefined checks. Save
+ // space when dealing with large number of arguments.
+ const list = parseOptions(options);
- // The parseOption method returns an array that include
- // the indices at which valid params are present.
- list.forEach((i) => {
- switch (i) {
- case REPORTEVENTS:
- if (Array.isArray(options.events))
- config.events = options.events;
- else
- throw new ERR_INVALID_ARG_TYPE('events',
- 'Array',
- options.events);
- break;
- case REPORTSIGNAL:
- if (typeof options.signal !== 'string') {
- throw new ERR_INVALID_ARG_TYPE('signal',
- 'String',
- options.signal);
- }
- process.removeListener(config.signal, handleSignal);
- if (config.events.includes('signal'))
- process.on(options.signal, handleSignal);
- config.signal = options.signal;
- break;
- case REPORTFILENAME:
- if (typeof options.filename !== 'string') {
- throw new ERR_INVALID_ARG_TYPE('filename',
- 'String',
- options.filename);
- }
- config.filename = options.filename;
- break;
- case REPORTPATH:
- if (typeof options.path !== 'string')
- throw new ERR_INVALID_ARG_TYPE('path', 'String', options.path);
- config.path = options.path;
- break;
- case REPORTVERBOSE:
- if (typeof options.verbose !== 'string' &&
- typeof options.verbose !== 'boolean') {
- throw new ERR_INVALID_ARG_TYPE('verbose',
- 'Booelan | String' +
- ' (true|false|yes|no)',
- options.verbose);
- }
- config.verbose = options.verbose;
- break;
- }
- });
- // Upload this new config to C++ land
- nr.syncConfig(config, true);
- },
+ // Flush the stale entries from report, as
+ // we are refreshing it, items that the users did not
+ // touch may be hanging around stale otherwise.
+ config = {};
+
+ // The parseOption method returns an array that include
+ // the indices at which valid params are present.
+ list.forEach((i) => {
+ switch (i) {
+ case REPORTEVENTS:
+ if (Array.isArray(options.events))
+ config.events = options.events;
+ else
+ throw new ERR_INVALID_ARG_TYPE('events',
+ 'Array',
+ options.events);
+ break;
+ case REPORTSIGNAL:
+ if (typeof options.signal !== 'string') {
+ throw new ERR_INVALID_ARG_TYPE('signal',
+ 'String',
+ options.signal);
+ }
+ process.removeListener(config.signal, handleSignal);
+ if (config.events.includes('signal'))
+ process.on(options.signal, handleSignal);
+ config.signal = options.signal;
+ break;
+ case REPORTFILENAME:
+ if (typeof options.filename !== 'string') {
+ throw new ERR_INVALID_ARG_TYPE('filename',
+ 'String',
+ options.filename);
+ }
+ config.filename = options.filename;
+ break;
+ case REPORTPATH:
+ if (typeof options.path !== 'string')
+ throw new ERR_INVALID_ARG_TYPE('path', 'String', options.path);
+ config.path = options.path;
+ break;
+ case REPORTVERBOSE:
+ if (typeof options.verbose !== 'string' &&
+ typeof options.verbose !== 'boolean') {
+ throw new ERR_INVALID_ARG_TYPE('verbose',
+ 'Booelan | String' +
+ ' (true|false|yes|no)',
+ options.verbose);
+ }
+ config.verbose = options.verbose;
+ break;
+ }
+ });
+ // Upload this new config to C++ land
+ nr.syncConfig(config, true);
+ },
- triggerReport(file, err) {
- emitExperimentalWarning('report');
- if (err == null) {
- if (file == null) {
- return nr.triggerReport(new ERR_SYNTHETIC(
- 'JavaScript Callstack').stack);
- }
- if (typeof file !== 'string')
- throw new ERR_INVALID_ARG_TYPE('file', 'String', file);
- return nr.triggerReport(file, new ERR_SYNTHETIC(
+ triggerReport(file, err) {
+ emitExperimentalWarning('report');
+ if (err == null) {
+ if (file == null) {
+ return nr.triggerReport(new ERR_SYNTHETIC(
'JavaScript Callstack').stack);
}
- if (typeof err !== 'object')
- throw new ERR_INVALID_ARG_TYPE('err', 'Object', err);
- if (file == null)
- return nr.triggerReport(err.stack);
if (typeof file !== 'string')
throw new ERR_INVALID_ARG_TYPE('file', 'String', file);
- return nr.triggerReport(file, err.stack);
- },
- getReport(err) {
- emitExperimentalWarning('report');
- if (err == null) {
- return nr.getReport(new ERR_SYNTHETIC('JavaScript Callstack').stack);
- } else if (typeof err !== 'object') {
- throw new ERR_INVALID_ARG_TYPE('err', 'Objct', err);
- } else {
- return nr.getReport(err.stack);
- }
+ return nr.triggerReport(file, new ERR_SYNTHETIC(
+ 'JavaScript Callstack').stack);
}
- };
+ if (typeof err !== 'object')
+ throw new ERR_INVALID_ARG_TYPE('err', 'Object', err);
+ if (file == null)
+ return nr.triggerReport(err.stack);
+ if (typeof file !== 'string')
+ throw new ERR_INVALID_ARG_TYPE('file', 'String', file);
+ return nr.triggerReport(file, err.stack);
+ },
+ getReport(err) {
+ emitExperimentalWarning('report');
+ if (err == null) {
+ return nr.getReport(new ERR_SYNTHETIC('JavaScript Callstack').stack);
+ } else if (typeof err !== 'object') {
+ throw new ERR_INVALID_ARG_TYPE('err', 'Objct', err);
+ } else {
+ return nr.getReport(err.stack);
+ }
+ }
+ };
- // Download the CLI / ENV config into JS land.
- nr.syncConfig(config, false);
+ // Download the CLI / ENV config into JS land.
+ nr.syncConfig(config, false);
- function handleSignal(signo) {
- if (typeof signo !== 'string')
- signo = config.signal;
- nr.onUserSignal(signo);
- }
+ function handleSignal(signo) {
+ if (typeof signo !== 'string')
+ signo = config.signal;
+ nr.onUserSignal(signo);
+ }
- if (config.events.includes('signal')) {
- process.on(config.signal, handleSignal);
- }
+ if (config.events.includes('signal')) {
+ process.on(config.signal, handleSignal);
+ }
- function parseOptions(obj) {
- const list = [];
- if (obj == null)
- return list;
- if (obj.events != null)
- list.push(REPORTEVENTS);
- if (obj.signal != null)
- list.push(REPORTSIGNAL);
- if (obj.filename != null)
- list.push(REPORTFILENAME);
- if (obj.path != null)
- list.push(REPORTPATH);
- if (obj.verbose != null)
- list.push(REPORTVERBOSE);
+ function parseOptions(obj) {
+ const list = [];
+ if (obj == null)
return list;
- }
- process.report = report;
+ if (obj.events != null)
+ list.push(REPORTEVENTS);
+ if (obj.signal != null)
+ list.push(REPORTSIGNAL);
+ if (obj.filename != null)
+ list.push(REPORTFILENAME);
+ if (obj.path != null)
+ list.push(REPORTPATH);
+ if (obj.verbose != null)
+ list.push(REPORTVERBOSE);
+ return list;
}
+ process.report = report;
};