winstonjs / winston-daily-rotate-file

A transport for winston which logs to a rotating file each day.
MIT License
899 stars 156 forks source link

Error from file-stream-rotator #362

Closed johnfung95 closed 1 year ago

johnfung95 commented 2 years ago

Hi, I have encountered an error from file-stream-rotator recently.

node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: UNKNOWN: unknown error, write
Emitted 'error' event at:
    at WriteStream.<anonymous> (Z:\program\node_modules\file-stream-rotator\FileStreamRotator.js:697:15)
    at WriteStream.emit (node:events:513:28)
    at WriteStream.emit (node:domain:489:12)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -4094,
  code: 'UNKNOWN',
  syscall: 'write'
}

Node.js v18.12.1

After some checking, I learned that the file-stream-rotator has published version 1.0, while the winston-daily-rotate-file is still using v0.6.1. May I know if the above error stems from the out-of-date package from your side?

My configuration for the file is simply the following:

const DailyRotateFile = require("winston-daily-rotate-file");
var transport = new DailyRotateFile({
  filename: "logs/nodeJs_%DATE%.log",
  datePattern: "YYYY-MM-DD",
  zippedArchive: false,
  maxSize: "20m",
  maxFiles: "14d",
});
johnfung95 commented 1 year ago

hi, not sure if it is related or not, but the problem does not persist anymore after I downgraded the winston to v3.7.2.

wbt commented 1 year ago

That is useful information about the downgrade, thank you. Do you have handy a complete minimal example that reproduces the error?

johnfung95 commented 1 year ago

Sorry, turns out the error occurred because of insufficient permission to folder. When full permission is acquired, the error does not occur anymore.

For information, the program is being placed in a network drive to run, hence the permission is essential for some read / write procedures.