Structured JSON diagnostic reports at the exact moment of failure — integrating into SRE pipelines without the overhead of full core dump analysis.
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.reportgenerates 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
A process.report output is a JSON file with these sections:
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.
Configuration: Triggering Reports Automatically
Kubernetes Integration: Report Before OOM Kill
When Kubernetes sends SIGTERM before OOM killing a pod, trigger a report in the SIGTERM handler:
Reading a Diagnostic Report: The Key Sections
Diagnosing OOM from a Report
Diagnosing Resource Leaks from libuv Section
Diagnosing Event Loop Stall
SRE Pipeline Integration
Automatic Report Upload on Crash
Alert on Crash with Report Link
Programmatic Report Inspection
Course Complete
This module closes the course. The full arc from Module 0 to Module 20:
Foundation (0–5): Non-blocking architecture, V8 internals, event loop mechanics, kernel I/O, backpressure, off-heap buffers.
Scaling (6–9): Cluster/workers/IPC, routing engines, Modulith architecture, microservice extraction.
Distributed Systems (10–11): gRPC, Kafka, event sourcing, DDD, CQRS, Clean Architecture.
Operations (12–13): Observability, flame graphs, connection pooling, PM2, graceful shutdown.
Advanced (14–20): Edge isolates, resiliency runbooks, Permission Model, SEA/snapshots, Rust N-API, Undici/Web Crypto, automated diagnostics.
The system you can now build: a high-throughput Node.js blockchain indexer or payment gateway that uses kernel-level I/O efficiently, scales across all available CPU cores with minimal IPC overhead, maintains clean domain boundaries with CQRS and DDD, defends against supply chain attacks and ReDoS, and generates structured diagnostics at the exact moment of any failure.
Summary
| Concept | Key Takeaway |
|---|---|
process.report | Structured JSON at the moment of failure. V8 heap, libuv handles, call stacks, env vars. |
reportOnFatalError | Captures report on OOM, segfault, other fatal errors. No code change needed after configuration. |
reportOnSignal | SIGUSR2 triggers a report in a running process. Zero impact on traffic. |
writeReport() | Programmatic report generation in signal handlers and error handlers. |
| Heap section | usedMemory / totalMemory > 95% = OOM. Old Space full = memory leak. |
| libuv section | 400 TCP connections to one host = connection leak. Unexpected handles = resource leak. |
| CPU section | High user CPU, low kernel CPU = JavaScript blocking the event loop. |
| S3 upload before exit | Persist reports from ephemeral Kubernetes pods before they disappear. |
| Automated analysis | Parse reports in CI/CD load tests to detect memory leaks before production. |
How can you configure Node.js to automatically capture the V8 heap state and open file descriptors exactly when the process crashes from an Out of Memory (OOM) error?
What does the presence of hundreds of identical outgoing TCP connection entries (e.g., { "type": "tcp", "address": "db.internal", "port": 5432 }) in the libuv section of a process.report most likely indicate?
What is the recommended way to reliably capture and preserve a process.report when Kubernetes shuts down a pod via a SIGTERM signal?
Test your knowledge with more question sets
Sign in to access a wider variety of questions and get notified when new practice sets are added to this module.
Sign in & RegisterDiscussion
0Join the discussion