mirror of
https://github.com/nodejs/node.git
synced 2024-11-22 11:12:18 +00:00
009665fb56
New option `--report-exclude-network`, also available as `report.excludeNetwork`, enables the user to exclude networking interfaces in their diagnostic report. On some systems, this can cause the report to take minutes to generate so this option can be used to optimize that. Fixes: https://github.com/nodejs/node/issues/46060 PR-URL: https://github.com/nodejs/node/pull/51645 Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
42 lines
1.4 KiB
JavaScript
42 lines
1.4 KiB
JavaScript
'use strict';
|
|
require('../common');
|
|
const assert = require('node:assert');
|
|
const { spawnSync } = require('node:child_process');
|
|
const tmpdir = require('../common/tmpdir');
|
|
const { describe, it, before } = require('node:test');
|
|
const fs = require('node:fs');
|
|
const helper = require('../common/report');
|
|
|
|
function validate(pid) {
|
|
const reports = helper.findReports(pid, tmpdir.path);
|
|
assert.strictEqual(reports.length, 1);
|
|
let report = fs.readFileSync(reports[0], { encoding: 'utf8' });
|
|
report = JSON.parse(report);
|
|
assert.strictEqual(report.header.networkInterfaces, undefined);
|
|
fs.unlinkSync(reports[0]);
|
|
}
|
|
|
|
describe('report exclude network option', () => {
|
|
before(() => {
|
|
tmpdir.refresh();
|
|
process.report.directory = tmpdir.path;
|
|
});
|
|
|
|
it('should be configurable with --report-exclude-network', () => {
|
|
const args = ['--report-exclude-network', '-e', 'process.report.writeReport()'];
|
|
const child = spawnSync(process.execPath, args, { cwd: tmpdir.path });
|
|
assert.strictEqual(child.status, 0);
|
|
assert.strictEqual(child.signal, null);
|
|
validate(child.pid);
|
|
});
|
|
|
|
it('should be configurable with report.excludeNetwork', () => {
|
|
process.report.excludeNetwork = true;
|
|
process.report.writeReport();
|
|
validate(process.pid);
|
|
|
|
const report = process.report.getReport();
|
|
assert.strictEqual(report.header.networkInterfaces, undefined);
|
|
});
|
|
});
|