Skip to content

Commit 4f38106

Browse files
vipinmenontargos
authored andcommitted
doc: add node-report documentation
a separate section added for node-report at top level main documentation added to doc/api/report.md API documentation added to doc/api/process.md PR-URL: #22712 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <Michael_Dawson@ca.ibm.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
1 parent 549216a commit 4f38106

File tree

6 files changed

+720
-0
lines changed

6 files changed

+720
-0
lines changed

doc/api/cli.md

+73
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,64 @@ $ node --completion-bash > node_bash_completion
7575
$ source node_bash_completion
7676
```
7777

78+
### `--diagnostic-report-directory=directory`
79+
<!-- YAML
80+
added: REPLACEME
81+
-->
82+
83+
Location at which the report will be generated.
84+
85+
### `--diagnostic-report-filename=filename`
86+
<!-- YAML
87+
added: REPLACEME
88+
-->
89+
90+
Name of the file to which the report will be written.
91+
92+
### `--diagnostic-report-on-fatalerror`
93+
<!-- YAML
94+
added: REPLACEME
95+
-->
96+
97+
Enables the report to be triggered on fatal errors (internal errors within
98+
the Node.js runtime such as out of memory) that lead to termination of the
99+
application, if `--experimental-report` is enabled. Useful to inspect various
100+
diagnostic data elements such as heap, stack, event loop state, resource
101+
consumption etc. to reason about the fatal error.
102+
103+
### `--diagnostic-report-on-signal`
104+
<!-- YAML
105+
added: REPLACEME
106+
-->
107+
108+
Enables report to be generated upon receiving the specified (or predefined)
109+
signal to the running Node.js process, if `--experimental-report` is enabled.
110+
The signal to trigger the report is specified through `--diagnostic-report-signal`.
111+
112+
### `--diagnostic-report-signal=signal`
113+
<!-- YAML
114+
added: REPLACEME
115+
-->
116+
117+
Sets or resets the signal for report generation (not supported on Windows).
118+
Default signal is `SIGUSR2`.
119+
120+
### `--diagnostic-report-uncaught-exception`
121+
<!-- YAML
122+
added: REPLACEME
123+
-->
124+
125+
Enables report to be generated on un-caught exceptions, if
126+
`--experimental-report` is enabled. Useful when inspecting JavaScript stack in
127+
conjunction with native stack and other runtime environment data.
128+
129+
### `--diagnostic-report-verbose`
130+
<!-- YAML
131+
added: REPLACEME
132+
-->
133+
134+
Flag that enables additional information to be printed during report generation.
135+
78136
### `--enable-fips`
79137
<!-- YAML
80138
added: v6.0.0
@@ -104,6 +162,13 @@ added: v10.0.0
104162

105163
Enable experimental top-level `await` keyword support in REPL.
106164

165+
### `--experimental-report`
166+
<!-- YAML
167+
added: REPLACEME
168+
-->
169+
170+
Enable experimental diagnostic report feature.
171+
107172
### `--experimental-vm-modules`
108173
<!-- YAML
109174
added: v9.6.0
@@ -600,9 +665,17 @@ if they had been specified on the command line before the actual command line
600665
that is not allowed in the environment is used, such as `-p` or a script file.
601666

602667
Node.js options that are allowed are:
668+
- `--diagnostic-report-directory`
669+
- `--diagnostic-report-filename`
670+
- `--diagnostic-report-on-fatalerror`
671+
- `--diagnostic-report-on-signal`
672+
- `--diagnostic-report-signal`
673+
- `--diagnostic-report-uncaught-exception`
674+
- `--diagnostic-report-verbose`
603675
- `--enable-fips`
604676
- `--experimental-modules`
605677
- `--experimental-repl-await`
678+
- `--experimental-report`
606679
- `--experimental-vm-modules`
607680
- `--force-fips`
608681
- `--icu-data-dir`

doc/api/errors.md

+6
Original file line numberDiff line numberDiff line change
@@ -1689,6 +1689,12 @@ called.
16891689
An attempt has been made to create a string longer than the maximum allowed
16901690
length.
16911691

1692+
<a id="ERR_SYNTHETIC"></a>
1693+
#### ERR_SYNTHETIC
1694+
1695+
An artificial error object used to capture call stack when diagnostic report
1696+
is produced.
1697+
16921698
<a id="ERR_SYSTEM_ERROR"></a>
16931699
### ERR_SYSTEM_ERROR
16941700

doc/api/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
* [Query Strings](querystring.html)
4646
* [Readline](readline.html)
4747
* [REPL](repl.html)
48+
* [Report](report.html)
4849
* [Stream](stream.html)
4950
* [String Decoder](string_decoder.html)
5051
* [Timers](timers.html)

doc/api/process.md

+104
Original file line numberDiff line numberDiff line change
@@ -1658,6 +1658,109 @@ In custom builds from non-release versions of the source tree, only the
16581658
`name` property may be present. The additional properties should not be
16591659
relied upon to exist.
16601660

1661+
## process.report
1662+
1663+
### process.report.getReport([err])
1664+
<!-- YAML
1665+
added: REPLACEME
1666+
-->
1667+
1668+
* `err` {Object}
1669+
* Returns: {Object} Returns the diagnostics report as an `Object`.
1670+
1671+
Generates a JSON-formatted diagnostic report summary of the running process.
1672+
The report includes JavaScript and native stack traces, heap statistics,
1673+
platform information, resource usage etc.
1674+
1675+
```js
1676+
const data = process.report.getReport();
1677+
console.log(data);
1678+
```
1679+
1680+
Additional documentation on diagnostic report is available
1681+
at [report documentation][].
1682+
1683+
### process.report.setDiagnosticReportOptions([options]);
1684+
<!-- YAML
1685+
added: REPLACEME
1686+
-->
1687+
1688+
Set the runtime configuration of diagnostic report data capture. Upon invocation
1689+
of this function, the runtime is reconfigured to generate report based on
1690+
the new input.
1691+
1692+
* `options` {Object}
1693+
* `events` {string[]}
1694+
* `signal`: generate a report in response to a signal raised on the process.
1695+
* `exception`: generate a report on unhandled exceptions.
1696+
* `fatalerror`: generate a report on internal fault
1697+
(such as out of memory errors or native assertions).
1698+
* `signal` {string} sets or resets the signal for report generation
1699+
(not supported on Windows). **Default:** `'SIGUSR2'`.
1700+
* `filename` {string} name of the file to which the report will be written.
1701+
* `path` {string} drectory at which the report will be generated.
1702+
**Default:** the current working directory of the Node.js process.
1703+
* `verbose` {boolean} flag that controls additional verbose information on
1704+
report generation. **Default:** `false`.
1705+
1706+
```js
1707+
// Trigger a report upon uncaught exceptions or fatal erros.
1708+
process.report.setDiagnosticReportOptions(
1709+
{ events: ['exception', 'fatalerror'] });
1710+
1711+
// Change the default path and filename of the report.
1712+
process.report.setDiagnosticReportOptions(
1713+
{ filename: 'foo.json', path: '/home' });
1714+
1715+
// Produce the report onto stdout, when generated. Special meaning is attached
1716+
// to `stdout` and `stderr`. Usage of these will result in report being written
1717+
// to the associated standard streams. URLs are not supported.
1718+
process.report.setDiagnosticReportOptions(
1719+
{ filename: 'stdout' });
1720+
1721+
// Enable verbose option on report generation.
1722+
process.report.setDiagnosticReportOptions(
1723+
{ verbose: true });
1724+
1725+
```
1726+
1727+
Signal based report generation is not supported on Windows.
1728+
1729+
Additional documentation on diagnostic report is available
1730+
at [report documentation][].
1731+
1732+
### process.report.triggerReport([filename][, err])
1733+
<!-- YAML
1734+
added: REPLACEME
1735+
-->
1736+
1737+
* `filename` {string} The file to write into. The `filename` should be
1738+
a relative path, that will be appended to the directory specified by
1739+
`process.report.setDiagnosticReportOptions`, or current working directory
1740+
of the Node.js process, if unspecified.
1741+
* `err` {Object} A custom object which will be used for reporting
1742+
JavsScript stack.
1743+
1744+
* Returns: {string} Returns the filename of the generated report.
1745+
1746+
If both `filename` and `err` object are passed to `triggerReport()` the
1747+
`err` object must be the second parameter.
1748+
1749+
Triggers and produces the report (a JSON-formatted file with the internal
1750+
state of Node.js runtime) synchronously, and writes into a file.
1751+
1752+
```js
1753+
process.report.triggerReport();
1754+
```
1755+
1756+
When a report is triggered, start and end messages are issued to stderr and the
1757+
filename of the report is returned to the caller. The default filename includes
1758+
the date, time, PID and a sequence number. Alternatively, a filename and error
1759+
object can be specified as parameters on the `triggerReport()` call.
1760+
1761+
Additional documentation on diagnostic report is available
1762+
at [report documentation][].
1763+
16611764
## process.send(message[, sendHandle[, options]][, callback])
16621765
<!-- YAML
16631766
added: v0.5.9
@@ -2172,3 +2275,4 @@ cases:
21722275
[note on process I/O]: process.html#process_a_note_on_process_i_o
21732276
[process_emit_warning]: #process_process_emitwarning_warning_type_code_ctor
21742277
[process_warning]: #process_event_warning
2278+
[report documentation]: report.html

0 commit comments

Comments
 (0)