Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

node-report

nodejs682MITdeprecated2.2.11

This module has been superseded by the diagnostics report feature of Node.js core. It is now unmaintained.

Diagnostic Report for Node.js

readme

node-report

Delivers a human-readable diagnostic summary, written to file.

The report is intended for development, test and production use, to capture and preserve information for problem determination. It includes JavaScript and native stack traces, heap statistics, platform information and resource usage etc. With the report enabled, reports can be triggered on unhandled exceptions, fatal errors, signals and calls to a JavaScript API.

Supports Node.js versions 8, 10 and 12 on AIX, Linux, macOS, SmartOS and Windows. Node.js 12 and later contain similar functionality in the built-in Diagnostic Report feature.

NOTE: This repo will be archived and the npm package will be sunset in lieu of Diagnostic Report, when Node.js 10 enters End-of-Life.

Usage

npm install node-report
node -r node-report app.js

A report will be triggered automatically on unhandled exceptions and fatal error events (for example out of memory errors), and can also be triggered by sending a USR2 signal to a Node.js process (not supported on Windows).

A report can also be triggered via an API call from a JavaScript application.

var nodereport = require('node-report');
nodereport.triggerReport();

The content of a report can also be returned as a JavaScript string via an API call from a JavaScript application.

var nodereport = require('node-report');
var report_str = nodereport.getReport();
console.log(report_str);

The API can be used without adding the automatic exception and fatal error hooks and the signal handler, as follows:

var nodereport = require('node-report/api');
nodereport.triggerReport();

Content of the report consists of a header section containing the event type, date, time, PID and Node version, sections containing JavaScript and native stack traces, a section containing V8 heap information, a section containing libuv handle information and an OS platform information section showing CPU and memory usage and system limits. An example report can be triggered using the Node.js REPL:

$ node
> nodereport = require('node-report')
> nodereport.triggerReport()
Writing Node.js report to file: node-report.20161020.091102.8480.001.txt
Node.js report completed
>

When a report is triggered, start and end messages are issued to stderr and the filename of the report is returned to the caller. The default filename includes the date, time, PID and a sequence number. Alternatively, a filename can be specified as a parameter on the triggerReport() call.

nodereport.triggerReport("myReportName");

Both triggerReport() and getReport() can take an optional Error object as a parameter. If an Error object is provided, the message and stack trace from the object will be included in the report in the JavaScript Exception Details section. When using node-report to handle errors in a callback or an exception handler this allows the report to include the location of the original error as well as where it was handled. If both a filename and Error object are passed to triggerReport() the Error object should be the second parameter.

try {
  process.chdir('/foo/foo');
} catch (err) {
  nodereport.triggerReport(err);
}
  ...
});

Configuration

Additional configuration is available using the following APIs:

var nodereport = require('node-report/api');
nodereport.setEvents("exception+fatalerror+signal+apicall");
nodereport.setSignal("SIGUSR2|SIGQUIT");
nodereport.setFileName("stdout|stderr|<filename>");
nodereport.setDirectory("<full path>");
nodereport.setVerbose("yes|no");

Configuration on module initialization is also available via environment variables:

export NODEREPORT_EVENTS=exception+fatalerror+signal+apicall
export NODEREPORT_SIGNAL=SIGUSR2|SIGQUIT
export NODEREPORT_FILENAME=stdout|stderr|<filename>
export NODEREPORT_DIRECTORY=<full path>
export NODEREPORT_VERBOSE=yes|no

Examples

To see examples of reports generated from these events you can run the demonstration applications provided in the node-report github repository. These are Node.js applications which will prompt you to trigger the required event.

  1. api.js - report triggered by JavaScript API call.
  2. exception.js - report triggered by unhandled exception.
  3. fatalerror.js - report triggered by fatal error on JavaScript heap out of memory.
  4. loop.js - looping application, report triggered using kill -USR2 <pid>.

License

Licensed under the MIT License.

changelog

2020-07-03, Version 2.2.11

  • build: disable compiler inlining on z/OS (#146) (Gaby Baghdadi)

  • readme: add sunset info (#144) (Gireesh Punathil)

2020-01-12, Version 2.2.10

  • Add hostname to Machine line on AIX (#141) (Richard Lau)

2019-10-31, Version 2.2.9

  • Apply EBCDIC to ASCII conversions only if node wasn't built with -qASCII (#138) (Gaby Baghdadi)

2019-07-10, Version 2.2.8

  • Fix npm audit warning (#136) (Richard Lau)

  • Update supported Node.js versions in README.md (#134) (Richard Lau)

2019-06-06, Version 2.2.7

  • Add support for z/OS (#129) (Gaby Baghdadi)

2019-04-02, Version 2.2.6

  • Restore uppercase C++ method names (Richard Lau)

2019-03-31, Version 2.2.5

  • Remove setCoreDump (Richard Lau)

  • Use nan helpers to set exports (Richard Lau)

2019-03-17, Version 2.2.4

  • Fix use of deprecated methods removed in V8 7.0 (Richard Lau)

2019-03-05, Version 2.2.3

  • Fix CI failures on ubuntu1804 (Richard Lau)

  • chore: update dependencies (Richard Lau)

2019-01-22, Version 2.2.2

  • Fix use of deprecated methods removed in V8 7.0 (Richard Lau)

  • Fix build on Windows with libuv 1.22 and later (Richard Lau)

  • Rename LICENCE.md to LICENSE.md (Julian Alimin)

  • Update README.md to correct code example (Manusaporn Treerungroj)

  • Add event loop thread times to node-report on OSX, which doesn't support RUSAGE_THREAD. (Howard Hellyer)

  • Replace node::signo_string with local implementation (Richard Chamberlain)

2017-09-26, Version 2.2.1

  • Update README to show support for Node.js 8 (Richard Chamberlain)

  • Remove use of std::map to sort version strings (Richard Chamberlain)

  • Restructure node_report.cc, move functions to utilities.cc (Richard Chamberlain)

  • Fix compile and linking issues on Alpine Linux (Richard Chamberlain)

2017-05-30, Version 2.2.0

  • Additional information for libuv handles (Richard Lau)

  • node_report.cc: Fix CreateMessage call (Howard Hellyer)

  • Allow Error object to be passed to node-report (Howard Hellyer)

  • windows: fix compile time error on mktime (Howard Hellyer)

  • report: add average CPU consumption (Bidisha Pyne)

  • Fix the use of %p to format handle pointers on non-Windows platforms. (Howard Hellyer)

  • report: add word-size of the process (LAKSHMI SWETHA GOPIREDDY)

2017-03-23, Version 2.1.2

  • Report compile time and runtime glibc version (Richard Lau)

  • Improve useability of node-report demos (Richard Chamberlain)

  • Fix return code from uncaught exception handler (Richard Chamberlain)

  • Increase tap timeout for CI testing (Richard Chamberlain)

  • test: Move OS version tests to common.js (Richard Lau)

  • docs: update platform support (Richard Lau)

  • smartos: enable node-report on SmartOS (Howard Hellyer)

2017-02-22, Version 2.1.1

  • windows: fix reporting of machine name (Richard Chamberlain)

  • test: fix test-api-getreport.js (Richard Lau)

  • aix: improve readability of os version (Richard Lau)

2017-02-13, Version 2.1.0

  • Provide getReport API to return the contents of node-report. (Howard Hellyer)

2017-02-09, Version 2.0.0

  • mac: Fix compilation errors (Howard Hellyer)

  • Rename nodereport module to node-report (Richard Chamberlain)

  • Fix source directory for install target (Richard Lau)

  • aix: skip command line check for test-fatal-error (Richard Lau)

  • Add the list of library files loaded by the process to nodereport. (Howard Hellyer)

  • docs: AIX supports triggering on USR2 signal (Richard Lau)

  • Fix behaviour on exception to match node default (Richard Chamberlain)

  • Adds the command line used to start the node process to nodereport. (Howard Hellyer)

  • Opt-in hooks and signal by default (Richard Chamberlain)

  • Fix for clang warning: libstdc++ is deprecated (Richard Chamberlain)

2016-12-12, Version 1.0.7

  • Fix version reporting in NodeReport section (Richard Lau)

  • Fix fprintf calls on Windows (Richard Lau)

2016-11-18, Version 1.0.6

  • Fix test-exception.js for PPC (Richard Lau)

  • Improve README.md (Jeremiah Senkpiel)

  • Improvement to Windows version reporting (Richard Lau)

  • Convert testcases to use tap (Richard Lau)

2016-11-10, Version 1.0.5

  • Fix for failure in fatal error (OOM) test (Richard Chamberlain)

  • Add support for nodereport on AIX (Richard Chamberlain)

  • Deleting AUTHORS file. (Richard Chamberlain)

  • Correct Javascript to JavaScript in README.md (Richard Chamberlain)

  • Correct upper-case NPM, should be lower-case (Richard Chamberlain)

  • Remove specific URLs for NPM (Richard Chamberlain)

  • Add MAINTAINER.md file to document NPM release procedure (Richard Chamberlain)

  • Set/correct package metadata in package.json (Richard Chamberlain)

  • README documentation improvements (Richard Chamberlain)

  • .gitignore the test autorun log file (Sam Roberts)

  • test: require this module using correct syntax (Sam Roberts)

  • .npmignore: do not pack unnecessary files (Sam Roberts)

  • .gitignore: ignore npm ephemera and node reports (Sam Roberts)

  • Need to define _STDCFORMAT_MACROS for some glibc versions (Richard Chamberlain)

2016-10-28, Version 1.0.4

  • First release!