{"record":{"id":"25313e44527f3850","repo":"winstonjs/winston","slug":"options-stream-will-be-removed-in-winston-4-use-w","errorCode":null,"errorMessage":"options.stream will be removed in winston@4. Use winston.transports.Stream","messagePattern":"options\\.stream will be removed in winston@4\\. Use winston\\.transports\\.Stream","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"lib/winston/transports/file.js","lineNumber":66,"sourceCode":"\n    // Setup the base stream that always gets piped to to handle buffering.\n    this._stream = new PassThrough();\n    this._stream.setMaxListeners(30);\n\n    // Bind this context for listener methods.\n    this._onError = this._onError.bind(this);\n\n    if (options.filename || options.dirname) {\n      throwIf('filename or dirname', 'stream');\n      this._basename = this.filename = options.filename\n        ? path.basename(options.filename)\n        : 'winston.log';\n\n      this.dirname = options.dirname || path.dirname(options.filename);\n      this.options = options.options || { flags: 'a' };\n    } else if (options.stream) {\n      // eslint-disable-next-line no-console\n      console.warn('options.stream will be removed in winston@4. Use winston.transports.Stream');\n      throwIf('stream', 'filename', 'maxsize');\n      this._dest = this._stream.pipe(this._setupStream(options.stream));\n      this.dirname = path.dirname(this._dest.path);\n      // We need to listen for drain events when write() returns false. This\n      // can make node mad at times.\n    } else {\n      throw new Error('Cannot log to file without filename or stream.');\n    }\n\n    this.maxsize = options.maxsize || null;\n    this.rotationFormat = options.rotationFormat || false;\n    this.zippedArchive = options.zippedArchive || false;\n    this.maxFiles = options.maxFiles || null;\n    this.eol = (typeof options.eol === 'string') ? options.eol : os.EOL;\n    this.tailable = options.tailable || false;\n    this.lazy = options.lazy || false;\n\n    // Internal state variables representing the number of files this instance","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/winstonjs/winston/blob/ff0b79de8562bb322c390fbc82fe71c11f373428/lib/winston/transports/file.js#L48-L84","documentation":"The File transport constructor accepts a deprecated options.stream (a writable stream to write logs into). In winston 4 this option is removed; the dedicated winston.transports.Stream transport is the supported way to pipe logs into an arbitrary stream. This is also validated by throwIf('stream', 'filename', 'maxsize') which throws if stream is combined with those options.","triggerScenarios":"Creating new winston.transports.File({ stream: someWritableStream }) instead of new winston.transports.Stream({ stream: ... }). Also throws when options.stream is combined with filename or maxsize.","commonSituations":"Migrating winston 2.x configs where File({stream}) was the standard stream-piping pattern; combining stream with filename during partial refactors; copying pre-3.0 transport configuration.","solutions":["Replace with winston.transports.Stream: new winston.transports.Stream({ stream: myStream }).","If writing to a file, drop stream and use options.filename (plus dirname/options) on the File transport.","Ensure stream is not passed together with filename or maxsize, which throws regardless of the warning."],"exampleFix":"// before\nnew winston.transports.File({ stream: process.stdout });\n// after\nnew winston.transports.Stream({ stream: process.stdout });","handlingStrategy":"type-guard","validationCode":"// Guard transport options before constructing File transport\nfunction assertNoFileStream(options) {\n  if (options && 'stream' in options) {\n    throw new TypeError(\"Use winston.transports.Stream for streams; 'stream' is removed in winston@4.\");\n  }\n}","typeGuard":"function isFileStreamOptions(options) {\n  return options != null && 'filename' in options && !('stream' in options);\n}","tryCatchPattern":null,"preventionTips":["Use winston.transports.Stream for any stream target; use File only with filename.","Never combine stream with filename or maxsize in File transport options.","Enable --pending-deprecation in CI to catch this warning before winston@4."],"tags":["deprecation","winston","transports","stream"],"backgroundTag":"deprecated-api-usage","analyzedSha":"ff0b79de8562bb322c390fbc82fe71c11f373428","analyzedAt":"2026-08-31T13:33:44.585Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}