Module A-21·13 min read

Structured JSON diagnostic reports at the exact moment of failure — integrating into SRE pipelines without the overhead of full core dump analysis.

JJS
Written by Jatin Jain Saraf · Senior Software Engineer

Module 20 — Automated Post-Mortem Diagnostics: process.report

What this module covers: When a Node.js process crashes with an uncaught exception, OOM kill, or fatal error, you typically have one chance to capture diagnostic information before the process terminates. process.report generates a structured JSON diagnostic report containing the V8 heap state, libuv handle and request queues, native C++ call stacks, environment variables, and system information — captured at the exact moment of failure. This module covers configuring diagnostic reports for production, integrating report generation into SRE alert pipelines, and reading the output to diagnose crashes that are otherwise invisible.


What a Diagnostic Report Contains

process.report is Node's flight data recorder — you never want to need it, but when the process goes down, it's the only artifact that survives to tell you what the engines looked like in the final second.

A process.report output is a JSON file with these sections:

json

In one file, you have: the exact error, the V8 heap state at failure time, every open file descriptor (TCP connections, sockets), environment variables, and CPU usage — without needing to attach a debugger or reproduce the crash.

Operational caveat: report generation can itself fail under severe OOM. Writing a report requires allocating memory to serialize the heap and handle state to JSON — if the process is already at the absolute edge of its memory limit when the fatal error fires, there may not be enough headroom left to produce the report at all, or the report may be truncated mid-write (a partial JSON file, or one missing the javascriptHeap section entirely). This is not a reason to skip reportOnFatalError — a truncated report with a stack trace is still far more useful than nothing — but don't assume the report is guaranteed to be complete during the worst OOM events, which are exactly the events where you need it most.

This is a real risk, not a hypothetical one. process.report does NOT redact anything by default — environmentVariables above is the raw, unmodified process.env, verbatim. If your process has DATABASE_URL, API_KEY, JWT secrets, or any other credential in its environment (which is the normal way to configure a production Node.js service), every diagnostic report contains those credentials in plaintext. A report generated on OOM or uncaught exception, written to disk and then uploaded to S3 or attached to a ticket, is a credential leak waiting to happen unless you explicitly redact it first — see the redaction step below, which must run before the report is persisted or shipped anywhere.


Configuration: Triggering Reports Automatically

javascript
bash

CLI-Flag Equivalents

Every option above can also be set as a startup flag, which is often preferable in containerized deployments where you want the behavior locked in from process launch — before any application code has a chance to run (or fail to run):

bash

Sign in to keep reading

The rest of this module is free — sign in with Google to unlock it and track your progress.

Sign in & Register

Discussion

0

Join the discussion

Loading comments...

© 2026 Jatin Jain Saraf (JJS). All rights reserved.