Diagnostics and reports
Prerequisite: node-readline-and-terminal-interfaces. Objective: Review redacted report fields. Tested locally on Node.js 22.16.0 Linux. Each example is independent. Use a fresh disposable working directory, save as main.mjs, then run node main.mjs. The harness uses a five-second timeout and synthetic environment. These are static code blocks, not ByteMind interactive execution.
How it works
process.report.getReport() returns a report object for the current process. The report can contain header, JavaScript and native stacks, heap summaries, resource usage and other environment information. Prefer explicit field selection rather than attempting to blacklist every secret. This fixture runs under a synthetic environment and prints only counts or booleans. Diagnostic reports differ from CPU profiles and heap snapshots: choose evidence based on the symptom. Trace events can record timeline categories; actual traces and inspector data may be sensitive, so keep them local and bounded. Do not collect an actual production report without authorization.
Read an allowlisted report summary
import assert from 'node:assert/strict';const report=process.report.getReport();assert.equal(report.header.nodejsVersion,process.version);console.log(JSON.stringify({versionMatches:true,hasHeapSummary:typeof report.javascriptHeap==='object'}));Expected output:
{"versionMatches":true,"hasHeapSummary":true}The real report is kept in memory; no environment variables, paths or stack traces are emitted.
Select fields from a synthetic report
const report={header:{nodejsVersion:'v22.fixture',commandLine:['private argument']},environmentVariables:{TOKEN:'synthetic-secret'},javascriptHeap:{usedMemory:100}};const safe={runtime:report.header.nodejsVersion,heapBytes:report.javascriptHeap.usedMemory};console.log(JSON.stringify(safe));Expected output:
{"runtime":"v22.fixture","heapBytes":100}An allowlist leaves command-line and environment data out; real review must also consider whether selected fields are sensitive.
Common mistakes
Never upload full reports, heap snapshots, or trace files without authorization and explicit redaction review.
Practice
For a process crash and a latency regression, choose distinct diagnostic artifacts and explain how you would redact them.
Reference candidate: node-diagnostics-and-reports-lookup (route unverified). Documentation: https://nodejs.org/download/release/v22.16.0/docs/api/report.html (opened).
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Diagnostics and reports — knowledge check
Apply the lesson to a fresh scenario and explain the evidence boundary.
Which artifact is intended to summarize process state?
Why use an allowlist for a shared report?
Does a report replace a sampled CPU profile?