diff --git a/doc/api/cli.md b/doc/api/cli.md index abfbbeea45b1..f4f206f4b2a0 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -1996,6 +1996,41 @@ added: v0.1.3 Print node command-line options. The output of this option is less detailed than this document. +### `--hide-internal-stack-frames` + + + +Collapse stack frames that originate from Node.js internal modules (those +whose file name starts with `node:internal/`), and from the wrapper scripts +Node.js generates around [`--eval`][] and stdin input, in printed stack +traces. Each +run of consecutive internal frames is replaced with a single +`at (N frames hidden)` line. Frames from user code and from +public built-in modules such as `node:fs` are kept. + +```console +$ node --hide-internal-stack-frames -e "require('node:fs').readFileSync('missing')" +... +Error: ENOENT: no such file or directory, open 'missing' + at Object.openSync (node:fs:779:18) + at Object.readFileSync (node:fs:625:35) + at [eval]:1:20 + at (7 frames hidden) { +... +``` + +This applies to `error.stack` and to the stack traces Node.js prints itself, +such as those from [`--trace-uncaught`][], [`--trace-exit`][], +[`--trace-sync-io`][], [`--process-timeout`][], and the JavaScript stack in a +[diagnostic report][]. + +Frames are collapsed after V8 collects them, so a trace still contains at most +[`Error.stackTraceLimit`][] frames. The flag affects only the default +formatter: an `Error.prepareStackTrace` function set by the user still +receives every frame, and [`util.getCallSites()`][] is unaffected. + ### `--icu-data-dir=file`