-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bug] Files may get reordered by the rotation job #107
Comments
Hi @gmasclet , Thank you for reporting. In the page you are referring, the previous line to the one you highlighted:
It seems checking Do you think it could be enough to solve your problem? Thank you |
Hi @iccicci, Thanks for your responsiveness 🙂 I think that checking My proposal would simply be to remove the
Let me know what you think about that. |
That would break this.
That would make required also the history file to be created with correct sort, in case somebody wants to enable the feature after some log files are already created. Since every system has its own requirements, probably your request could be accomplished with a new configuration option. My plan:
Does it work for you? |
Released |
Thanks a lot @iccicci! The
I wasn't aware about that rule, this explains why the "sort by time" statement can not be simply removed. I'm definitely interested if you can implement a new option so that the history file is never reordered once created. |
We're using
rotating-file-stream
to handle the rotation of our log files.We've recently noticed that the filenames are sometimes out of order in the history file, meaning that the rotation may delete another file than the oldest one.
Unless I'm wrong, in the
history()
method, the files are sorted by theirctime
. See the last line of the following extract:rotating-file-stream/index.ts
Lines 500 to 518 in 73165e2
And from what I see in the Node documentation on https://nodejs.org/api/fs.html#class-fsstats:
So, it seems that in some cases, the
ctime
of the file may be externally modified, which causes the history file to be reordered during the next rotation job.May I suggest we instead keep the history file order, disregarding the file
ctime
?The text was updated successfully, but these errors were encountered: