Node.js process.report.reportonFatalError() Property22 Feb 2025 | 4 min read In this article, we will discuss the process.report.reportonFatalError() property in Node.js with its syntax, parameters, and examples. What is the process.report.reportonFatalError() property in Node.js?The process object is a global object that stores information about and controls the current Node.js process. It is always available as a global in Node.js applications, so require() is unnecessary. It can also be accessed directly using require(), as shown below. If the process is complete, a diagnostic report is generated for fatal errors such as out-of-memory or failed C++ assertions when report.reportOnFatalError is set to true. The process.report.reportOnFatalError property in Node.js is part of the diagnostic reporting feature, which was introduced to assist developers in diagnosing and debugging issues that cause the Node.js process to crash or hang. This feature is especially useful when the program encounters a fatal mistake, and we want to figure out what went wrong. Syntax:It has the following syntax: Parameters:This property does not have any parameters. Return type:This property returns a boolean. Key Points of the Process.report.reportOnFatalError:
Example 1:Let us take an example to illustrate the Node.js process.report.reportonFatalError() property. Output: A fatal error occurred: This is a fatal error for testing purposes. Explanation:
Example 2:Let us take an example to illustrate the Node.js process.report.reportonFatalError() property. Output:
Unhandled Rejection at: Promise {
<rejected> Error: This is an unhandled promise rejection for testing purposes.
at Timeout._onTimeout (/home/cg/root/6676fbbe68ebe/main.js:15:20)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
} reason: Error: This is an unhandled promise rejection for testing purposes.
at Timeout._onTimeout (/home/cg/root/6676fbbe68ebe/main.js:15:20)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
Process running...
Explanation:
Conclusion:In conclusion, the process.report.reportOnFatalError property is a powerful Node.js feature that allows diagnostic reports to be generated automatically when fatal errors occur. This capability is invaluable for developers who want to keep their applications robust and resilient because it makes debugging easier and critical issues resolve faster. Next TopicNodejs-process-stderr-fd-property |
We request you to subscribe our newsletter for upcoming updates.