4771314
V2EX  ›  Node.js

关于 process.on uncaughtException unhandledRejection 使用的疑问

  •  
  •   4771314 · Oct 29, 2020 · 5449 views
    This topic created in 2034 days ago, the information mentioned may be changed or developed.
    process.on('uncaughtException',function name(error) {
        const msg = error ? Err.getThrowableMessage(error) : '未知错误';
        logger.error('全局异常 uncaughtException:' +  msg);
    });
    
    process.on('unhandledRejection',function name(error) {
        const msg = error ? Err.getThrowableMessage(error) : '未知错误';
        monitor.report(MONITOR.TEST_PORTRAIT_GLOBAL_REJECTION_COUNT);
    });
    

    server 需要用这种方式保证服务的稳定吗? 使用的是 koa 的框架

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   6029 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 02:59 · PVG 10:59 · LAX 19:59 · JFK 22:59
    ♥ Do have faith in what you're doing.