The IBM SDK for Node.js now includes node-report, a native npm module that provides a general-purpose diagnostic facility for Node.js applications. The node-report module writes a diagnostic report to file when an unhandled exception or fatal error event such as out-of-memory occurs, when requested via a JavaScript API, or (Unix and Mac platforms) on receipt of a USR2 signal sent to the Node.js process. It contains key information about the JavaScript application and the Node.js run-time, including JavaScript and C++ stacks, V8 heap statistics, per-process and per-thread CPU usage, environment variables and resource limits. The module is loaded into an application using the -r command-line option or a require() API call.

The node-report module is pre-installed in the IBM SDK for Node.js version 6.10.0, so there is no need to install the node-report npm yourself.

Reports can be enabled without any code changes, simply using the -r node-report command-line option when starting your Node.js application.

node -r node-report application.js

A report can also be triggered via API call from a JavaScript application. By default the report is written as a file, but it also be returned as a JavaScript string.

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

var report_str = nodereport.getReport();

If required, the node-report API can be enabled without adding the automatic exception and fatal error hooks and the signal handler, as follows:

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

Example report for out-of-memory error in a Node.js application

The following screen shot shows part of a report generated by the node-report module for an out-of-memory scenario, running the IBM SDK for Node.js version 6.10.0 on Linux on System x 64-bit.

For further information about the node-report module see:

Join The Discussion

Your email address will not be published. Required fields are marked *