On this page

P

process.report

History
Type:Object

process.report is an object whose methods are used to generate diagnostic reports for the current process. Additional documentation is available in the report documentation.

P

process.report.compact

History
Type:boolean

Write reports in a compact format, single-line JSON, more easily consumable by log processing systems than the default multi-line format designed for human consumption.

import { report } from 'node:process';

console.log(`Reports are compact? ${report.compact}`);
const { report } = require('node:process');

console.log(`Reports are compact? ${report.compact}`);
Type:string

Directory where the report is written. The default value is the empty string, indicating that reports are written to the current working directory of the Node.js process.

import { report } from 'node:process';

console.log(`Report directory is ${report.directory}`);
const { report } = require('node:process');

console.log(`Report directory is ${report.directory}`);
Type:string

Filename where the report is written. If set to the empty string, the output filename will be comprised of a timestamp, PID, and sequence number. The default value is the empty string.

If the value of process.report.filename is set to 'stdout' or 'stderr', the report is written to the stdout or stderr of the process respectively.

import { report } from 'node:process';

console.log(`Report filename is ${report.filename}`);
const { report } = require('node:process');

console.log(`Report filename is ${report.filename}`);
process.report.getReport(err?): Object
Attributes
err:Error
A custom error used for reporting the JavaScript stack.
Returns:Object

Returns a JavaScript Object representation of a diagnostic report for the running process. The report's JavaScript stack trace is taken from err, if present.

import { report } from 'node:process';
import util from 'node:util';

const data = report.getReport();
console.log(data.header.nodejsVersion);

// Similar to process.report.writeReport()
import fs from 'node:fs';
fs.writeFileSync('my-report.log', util.inspect(data), 'utf8');
const { report } = require('node:process');
const util = require('node:util');

const data = report.getReport();
console.log(data.header.nodejsVersion);

// Similar to process.report.writeReport()
const fs = require('node:fs');
fs.writeFileSync('my-report.log', util.inspect(data), 'utf8');

Additional documentation is available in the report documentation.

Type:boolean

If true, a diagnostic report is generated on fatal errors, such as out of memory errors or failed C++ assertions.

import { report } from 'node:process';

console.log(`Report on fatal error: ${report.reportOnFatalError}`);
const { report } = require('node:process');

console.log(`Report on fatal error: ${report.reportOnFatalError}`);
Type:boolean

If true, a diagnostic report is generated when the process receives the signal specified by process.report.signal.

import { report } from 'node:process';

console.log(`Report on signal: ${report.reportOnSignal}`);
const { report } = require('node:process');

console.log(`Report on signal: ${report.reportOnSignal}`);
Type:boolean

If true, a diagnostic report is generated on uncaught exception.

import { report } from 'node:process';

console.log(`Report on exception: ${report.reportOnUncaughtException}`);
const { report } = require('node:process');

console.log(`Report on exception: ${report.reportOnUncaughtException}`);
P

process.report.excludeEnv

History
Type:boolean

If true, a diagnostic report is generated without the environment variables.

Type:string

The signal used to trigger the creation of a diagnostic report. Defaults to 'SIGUSR2'.

import { report } from 'node:process';

console.log(`Report signal: ${report.signal}`);
const { report } = require('node:process');

console.log(`Report signal: ${report.signal}`);
process.report.writeReport(filename?, err?): string
Attributes
filename:string
Name of the file where the report is written. This should be a relative path, that will be appended to the directory specified in process.report.directory, or the current working directory of the Node.js process, if unspecified.
err:Error
A custom error used for reporting the JavaScript stack.
Returns:string
Returns the filename of the generated report.

Writes a diagnostic report to a file. If filename is not provided, the default filename includes the date, time, PID, and a sequence number. The report's JavaScript stack trace is taken from err, if present.

If the value of filename is set to 'stdout' or 'stderr', the report is written to the stdout or stderr of the process respectively.

import { report } from 'node:process';

report.writeReport();
const { report } = require('node:process');

report.writeReport();

Additional documentation is available in the report documentation.