{"record":{"id":"9fcf9267f7386a7d","repo":"winstonjs/winston","slug":"winston-not-exiting-process","errorCode":null,"errorMessage":"winston: not exiting process.","messagePattern":"winston: not exiting process\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"lib/winston/exception-handler.js","lineNumber":179,"sourceCode":"   * process.\n   * @param {Error} err - Error to handle\n   * @returns {mixed} - TODO: add return description.\n   * @private\n   */\n  _uncaughtException(err) {\n    const info = this.getAllInfo(err);\n    const handlers = this._getExceptionHandlers();\n    // Calculate if we should exit on this error\n    let doExit = typeof this.logger.exitOnError === 'function'\n      ? this.logger.exitOnError(err)\n      : this.logger.exitOnError;\n    let timeout;\n\n    if (!handlers.length && doExit) {\n      // eslint-disable-next-line no-console\n      console.warn('winston: exitOnError cannot be true with no exception handlers.');\n      // eslint-disable-next-line no-console\n      console.warn('winston: not exiting process.');\n      doExit = false;\n    }\n\n    function gracefulExit() {\n      debug('doExit', doExit);\n      debug('process._exiting', process._exiting);\n\n      if (doExit && !process._exiting) {\n        // Remark: Currently ignoring any exceptions from transports when\n        // catching uncaught exceptions.\n        if (timeout) {\n          clearTimeout(timeout);\n        }\n        // eslint-disable-next-line no-process-exit\n        process.exit(1);\n      }\n    }\n","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/winstonjs/winston/blob/ff0b79de8562bb322c390fbc82fe71c11f373428/lib/winston/exception-handler.js#L161-L197","documentation":"The companion warning emitted in the same _uncaughtException branch: after detecting exitOnError=true with zero handlers, winston prints 'winston: not exiting process.' and sets doExit=false so the process survives. It is informational — winston declined to exit because there were no handlers to flush exceptions to.","triggerScenarios":"Same as error 16: uncaughtException occurs, handlers.length === 0 and doExit was true; both warn lines print together in exception-handler.js:177-179.","commonSituations":"Production incidents where an app expected to crash on uncaught exceptions (for a supervisor to restart it) but silently kept running with corrupted state; configs where exitOnError was enabled for restart tooling but exception transports were never attached.","solutions":["Attach at least one exception handler (logger.exceptions.handle(...)) so exitOnError semantics work as intended.","If survival is desired, set exitOnError: false explicitly to document intent and remove the warnings.","If you need guaranteed process exit regardless of winston, add your own process.on('uncaughtException') handler that logs then calls process.exit(1)."],"exampleFix":"// before\nconst logger = winston.createLogger({ exitOnError: true }); // warns and does NOT exit\n// after\nconst logger = winston.createLogger({ exitOnError: true });\nlogger.exceptions.handle(new winston.transports.Console()); // now exits after handling","handlingStrategy":"fallback","validationCode":"const hasHandlers = logger.exceptions.handlers && logger.exceptions.handlers.size > 0;\nif (!hasHandlers) {\n  // decide explicitly: attach a handler or own the uncaughtException path yourself\n  process.on('uncaughtException', (err) => {\n    console.error(err);\n    process.exit(1);\n  });\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Decide the intended crash behavior explicitly: winston-handled exit vs. supervisor restart vs. keep running.","Attach an exceptions transport when you rely on exitOnError.","For guaranteed exits with cleanup, add your own process.on('uncaughtException') rather than depending on winston defaults."],"tags":["winston","exception-handler","exitonerror","process-lifecycle"],"backgroundTag":"exception-handler-misconfigured","analyzedSha":"ff0b79de8562bb322c390fbc82fe71c11f373428","analyzedAt":"2026-08-31T13:33:44.585Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}