-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Losing log messages due to file flushing race condition #150
Comments
It looks like I'm running into this as well on master e31885f. I seem to be I would love to create a test/repro for this, but I would think the right way to do In the meantime, manually flushing on log.transports.file.once('open', function(e){
log.transports.file.flush();
}); |
+1 |
I think I'm running into this same problem as well. Where should I put this code? log.transports.file.once('open', function(e){ And is log actually just the winston import like this? var log = require('winston'); |
+1 |
👍 Also experiencing this..temp fix works for now |
Also got that issue, temp fix seems to work... but can somebody fix it? |
I wonder if this was ever fixed? I still have the hack in place and I'm surprised this is not a problem for many more people... |
I still have the same problem in version 0.7.3. |
Also loosing log messages for File transport :( Console works fine but log file is missing most of the entries. I wonder why such critical issue isn't fixed after two years? winston: 0.7.3 |
+1 |
I've just worked around this by passing the file transport a stream instead of a filename:- { stream: fs.createWriteStream('/path/to/logfile', { flags: 'a' }), ... } Seems to be working, but early days! |
I've implemented my own logger instead, and ended up with something more flexible in many regards. |
Is it fixed? |
Yes. This should be fixed in the latest |
I don't know how to reproduce this issue in the first place because there is not enough information. I'll test it if somebody tells me how to reproduce the issue. |
It seems to be fixed in winston >= 0.8.0 (fixed in 0c28041). Below is a script you can use to reproduce the issue on previous versions of winston. After running the script, examine /tmp/foo.log to observe the missing log messages. Note that things are particularly bad on newer versions of node (e.g. 0.10.33) and older versions of winston (0.6.x).
|
@muirmanders thanks for the confirmation :). And yea the internal buffering started changing things due to the file stream implementation. Steps are being made to clean it up even more. |
This is still not fixed in daily-rotate-file.js. |
The DailyRotateTransport is also having the issue for my app. I am using winston@1.0.0 and v0.10.35. |
Using a File transport, some of my startup log messages are not making it to the log (but later messages show up fine). I also have a console Transport, and everything shows up fine there, so I know the messages are getting written. I am running winston v0.6.1, node v0.8.0, Mac OS X 10.7.3.
I do not have a test case to reproduce it, but I have identified the race condition with some debug output (from transports/file.js):
As you can see, once we start looping over _buffer in fush() there is no protection against writing more messages that may never get flushed. In this case "LOG MESSAGE 2" is the one that never shows up in my log (but "LOG MESSAGE 1" and later messages show up properly).
The text was updated successfully, but these errors were encountered: