-
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
File transport: lazy file creation #1507
File transport: lazy file creation #1507
Conversation
@@ -105,6 +108,10 @@ module.exports = class File extends TransportStream { | |||
return true; | |||
} | |||
|
|||
if (this.lazy) { | |||
this.open(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I worry whether this affects performance because this gets called on every log()
call -- we should check and see
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right! The first thing open
does when it's called, it's checking if it was already opened, but it's an overhead of extra function call in every log
operation. So, I will try to change this to flag check here and measure performance.
@@ -105,6 +108,10 @@ module.exports = class File extends TransportStream { | |||
return true; | |||
} | |||
|
|||
if (this.lazy) { | |||
this.open(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this work with e.g. file rotation? Maybe it's fine, but I think it would be good if we could add one more test case that makes sure file rotation still works as expected with lazy: true
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes indeed, current tests of file rotation don't have this covered. I will add some tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the lazy option messes up with rotation and stress tests. I think that it's because they are assuming immediate file creation (assertions are constructed that way), not that the outcome is invalid.
Thank you so much for looking into this! I left a few comments for your consideration. |
Thanks for the review! I will work on that. |
Closing this for now due to inactivity but please feel free to re-open anytime. |
This change tries to address the issue #1494.