事件:'uncaughtExceptionMonitor'
添加于:v13.7.0、v12.17.0
参数
err<Error> 未捕获的异常。origin<string> 指示异常是源自未处理的拒绝还是源自同步错误。可以是'uncaughtException'或'unhandledRejection'。后者用于在基于Promise的异步上下文中发生异常(或者如果Promise被拒绝)并且标志设置为--unhandled-rejectionsstrict或throw(这是默认值)并且拒绝未处理,或者在命令行入口点的 ES 模块静态加载阶段发生拒绝时。
'uncaughtExceptionMonitor' 事件在'uncaughtException' 事件被发出或通过  安装的钩子被调用之前发出。process.setUncaughtExceptionCaptureCallback() 
一旦发出 'uncaughtException' 事件,安装 'uncaughtExceptionMonitor' 侦听器不会改变行为。如果没有安装'uncaughtException' 监听器,该进程仍然会崩溃。
import process from 'node:process'; process.on('uncaughtExceptionMonitor', (err, origin) => { MyMonitoringTool.logSync(err, origin); }); // Intentionally cause an exception, but don't catch it. nonexistentFunc(); // Still crashes Node.jsconst process = require('node:process'); process.on('uncaughtExceptionMonitor', (err, origin) => { MyMonitoringTool.logSync(err, origin); }); // Intentionally cause an exception, but don't catch it. nonexistentFunc(); // Still crashes Node.js
相关用法
- Node.js proces 'uncaughtException'事件用法及代码示例
 - Node.js stream.Writable 'unpipe'事件用法及代码示例
 - Node.js proces 'unhandledRejection'事件用法及代码示例
 - Node.js http.ClientRequest 'upgrade'事件用法及代码示例
 - Node.js tls.Server 'keylog'事件用法及代码示例
 - Node.js http.Server 'clientError'事件用法及代码示例
 - Node.js cluste 'disconnect'事件用法及代码示例
 - Node.js proces 'exit'事件用法及代码示例
 - Node.js stream.Writable 'pipe'事件用法及代码示例
 - Node.js stream.Readable 'end'事件用法及代码示例
 - Node.js cluste 'fork'事件用法及代码示例
 - Node.js Http2Session 'remoteSettings'事件用法及代码示例
 - Node.js Worker 'listening'事件用法及代码示例
 - Node.js tls.Server 'resumeSession'事件用法及代码示例
 - Node.js InterfaceConstructor 'pause'事件用法及代码示例
 - Node.js fs.FSWatcher 'change'事件用法及代码示例
 - Node.js stream.Readable 'data'事件用法及代码示例
 - Node.js http.ClientRequest 'connect'事件用法及代码示例
 - Node.js Http2Session 'localSettings'事件用法及代码示例
 - Node.js REPLServer 'exit'事件用法及代码示例
 - Node.js cluste 'online'事件用法及代码示例
 - Node.js tls.TLSSocket 'session'事件用法及代码示例
 - Node.js Worker 'exit'事件用法及代码示例
 - Node.js cluste 'exit'事件用法及代码示例
 - Node.js Http2Stream 'trailers'事件用法及代码示例
 
注:本文由纯净天空筛选整理自nodejs.org大神的英文原创作品 'uncaughtExceptionMonitor'事件。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
