-
Notifications
You must be signed in to change notification settings - Fork 42
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
_writev doesn't wait for chunk log callbacks before calling its own callback #49
Comments
This may be related to other people reporting similar observations of |
Also this too: winstonjs/winston#228 (comment) I imagine this workaround works because they're bypassing the |
Fixs github issue winstonjs#49 This allows stream events such as 'finish' to work correctly on the transport stream instead of possibly triggering before the individual log calls have been finished.
Fixs github issue winstonjs#49 This allows stream events such as 'finish' to work correctly on the transport stream instead of possibly triggering before the individual log calls have been finished.
Made a commit to add a test to demonstrate the issue and a patch to fix it. #50 |
Yes, you are correct, my workaround ; which is itself inspired by other implementations reported in the issue tracker ; relies on the file Transport allowing access to the "private"
(instead of The worst part of this hack is the necessity to run the workaround for each registered transport, but as I could not find a reliable Winston accessor I had to allocate a I am sure there is a better way to implement this, but whatever worked at the time did the job for me. I simply had no time to look into Winston's internals. |
@indexzero How do I go about asking someone to look at this? |
+1 |
Function in question:
winston-transport/index.js
Lines 117 to 166 in 46db8f3
This implementation of _writev calls
callback
before all the callbacks ofthis.log(chunks[i]...)
are called. This means that the transport stream may seem finished even if the underlying implementation hasn't finished writing out all the chunks yet.We ran into this when we saw that during tests that when we close a winston logger, we would sometimes see a
finish
event be emitted from the logger before our transport finished writing its files.We're currently working around this by implementing our own logv for our transport since that gives us control over calling the callback to
_writev
only when each chunk is finished.I'm happy to try to construct a minimal example and/or provide a merge request to fix this. I just want to check here if this is something that's done by design or otherwise known.
The text was updated successfully, but these errors were encountered: