{"record":{"id":"7be2bd4f1ae94c4c","repo":"winstonjs/winston","slug":"winston-not-exiting-process-7be2bd","errorCode":null,"errorMessage":"winston: not exiting process.","messagePattern":"winston: not exiting process\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"lib/winston/rejection-handler.js","lineNumber":181,"sourceCode":"   * @param {Error} err - Error to handle\n   * @returns {mixed} - TODO: add return description.\n   * @private\n   */\n  _unhandledRejection(err) {\n    const info = this.getAllInfo(err);\n    const handlers = this._getRejectionHandlers();\n    // Calculate if we should exit on this error\n    let doExit =\n      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 rejection 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 rejections from transports when\n        // catching unhandled rejections.\n        if (timeout) {\n          clearTimeout(timeout);\n        }\n        // eslint-disable-next-line no-process-exit\n        process.exit(1);\n      }\n    }\n","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/winstonjs/winston/blob/ff0b79de8562bb322c390fbc82fe71c11f373428/lib/winston/rejection-handler.js#L163-L199","documentation":"Companion warning to the exitOnError message in RejectionHandler._unhandledRejection. Because there were no rejection handler transports, winston forces doExit = false and prints this warning to make clear the process will NOT exit despite exitOnError being true.","triggerScenarios":"An unhandled promise rejection fires when the rejection handler has zero transports and doExit was initially true; after warning 'exitOnError cannot be true with no rejection handlers.', winston prints this second line and continues running.","commonSituations":"Same as error 22: logger configured with exitOnError true but no rejection transports; operators expecting the process to die on a bad rejection and a supervisor to restart it — the process instead survives with silently dropped rejections.","solutions":["Register a rejection transport so rejections are logged and the exit path proceeds: logger.rejections.handle(transport).","If surviving is acceptable, treat this as informational and add your own process.on('unhandledRejection') logging to avoid silent drops.","Explicitly set exitOnError:false to acknowledge the intended behavior and remove confusion."],"exampleFix":"// before\nconst logger = winston.createLogger({ exitOnError: true });\n// (no rejection transports — process survives rejections)\n// after\nlogger.rejections.handle(\n  new winston.transports.File({ filename: 'logs/unhandledRejections.log' })\n);","handlingStrategy":"fallback","validationCode":"// Ensure the process still handles rejections the way you expect\nprocess.on('unhandledRejection', (reason) => {\n  console.error('Unhandled rejection after winston no-op:', reason);\n});","typeGuard":null,"tryCatchPattern":"process.on('unhandledRejection', (reason) => {\n  logger.error('unhandled rejection', { reason: String(reason) });\n  if (shouldExitOnError) process.exit(1); // own exit policy as fallback\n});","preventionTips":["Register a rejection transport so winston can exit instead of swallowing rejections.","Install a process-level unhandledRejection listener as a safety net.","Monitor startup logs for the 'not exiting process' warning in production."],"tags":["winston","unhandled-rejection","process-exit","configuration"],"backgroundTag":"unhandled-promise-rejection","analyzedSha":"ff0b79de8562bb322c390fbc82fe71c11f373428","analyzedAt":"2026-08-31T13:33:44.585Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}