mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
report: warn on process.report object access
Reduce the number of emitExperimentalWarning() call sites by making process.report emit a warning on access instead of each individual report function. PR-URL: https://github.com/nodejs/node/pull/26414 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Wyatt Preul <wpreul@gmail.com>
This commit is contained in:
@@ -41,7 +41,15 @@ function initializeReport() {
|
||||
return;
|
||||
}
|
||||
const { report } = require('internal/process/report');
|
||||
process.report = report;
|
||||
const { emitExperimentalWarning } = require('internal/util');
|
||||
Object.defineProperty(process, 'report', {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
get() {
|
||||
emitExperimentalWarning('report');
|
||||
return report;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setupSignalHandlers() {
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
'use strict';
|
||||
const {
|
||||
convertToValidSignal,
|
||||
emitExperimentalWarning
|
||||
} = require('internal/util');
|
||||
const { convertToValidSignal } = require('internal/util');
|
||||
const {
|
||||
ERR_INVALID_ARG_TYPE,
|
||||
ERR_SYNTHETIC
|
||||
@@ -11,8 +8,6 @@ const { validateString } = require('internal/validators');
|
||||
const nr = internalBinding('report');
|
||||
const report = {
|
||||
triggerReport(file, err) {
|
||||
emitExperimentalWarning('report');
|
||||
|
||||
if (typeof file === 'object' && file !== null) {
|
||||
err = file;
|
||||
file = undefined;
|
||||
@@ -27,8 +22,6 @@ const report = {
|
||||
return nr.triggerReport('JavaScript API', 'API', file, err.stack);
|
||||
},
|
||||
getReport(err) {
|
||||
emitExperimentalWarning('report');
|
||||
|
||||
if (err === undefined)
|
||||
err = new ERR_SYNTHETIC();
|
||||
else if (err === null || typeof err !== 'object')
|
||||
@@ -37,29 +30,23 @@ const report = {
|
||||
return nr.getReport(err.stack);
|
||||
},
|
||||
get directory() {
|
||||
emitExperimentalWarning('report');
|
||||
return nr.getDirectory();
|
||||
},
|
||||
set directory(dir) {
|
||||
emitExperimentalWarning('report');
|
||||
validateString(dir, 'directory');
|
||||
return nr.setDirectory(dir);
|
||||
},
|
||||
get filename() {
|
||||
emitExperimentalWarning('report');
|
||||
return nr.getFilename();
|
||||
},
|
||||
set filename(name) {
|
||||
emitExperimentalWarning('report');
|
||||
validateString(name, 'filename');
|
||||
return nr.setFilename(name);
|
||||
},
|
||||
get signal() {
|
||||
emitExperimentalWarning('report');
|
||||
return nr.getSignal();
|
||||
},
|
||||
set signal(sig) {
|
||||
emitExperimentalWarning('report');
|
||||
validateString(sig, 'signal');
|
||||
convertToValidSignal(sig); // Validate that the signal is recognized.
|
||||
removeSignalHandler();
|
||||
@@ -67,24 +54,18 @@ const report = {
|
||||
return nr.setSignal(sig);
|
||||
},
|
||||
get reportOnFatalError() {
|
||||
emitExperimentalWarning('report');
|
||||
return nr.shouldReportOnFatalError();
|
||||
},
|
||||
set reportOnFatalError(trigger) {
|
||||
emitExperimentalWarning('report');
|
||||
|
||||
if (typeof trigger !== 'boolean')
|
||||
throw new ERR_INVALID_ARG_TYPE('trigger', 'boolean', trigger);
|
||||
|
||||
return nr.setReportOnFatalError(trigger);
|
||||
},
|
||||
get reportOnSignal() {
|
||||
emitExperimentalWarning('report');
|
||||
return nr.shouldReportOnSignal();
|
||||
},
|
||||
set reportOnSignal(trigger) {
|
||||
emitExperimentalWarning('report');
|
||||
|
||||
if (typeof trigger !== 'boolean')
|
||||
throw new ERR_INVALID_ARG_TYPE('trigger', 'boolean', trigger);
|
||||
|
||||
@@ -93,12 +74,9 @@ const report = {
|
||||
addSignalHandler();
|
||||
},
|
||||
get reportOnUncaughtException() {
|
||||
emitExperimentalWarning('report');
|
||||
return nr.shouldReportOnUncaughtException();
|
||||
},
|
||||
set reportOnUncaughtException(trigger) {
|
||||
emitExperimentalWarning('report');
|
||||
|
||||
if (typeof trigger !== 'boolean')
|
||||
throw new ERR_INVALID_ARG_TYPE('trigger', 'boolean', trigger);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user