-
Notifications
You must be signed in to change notification settings - Fork 3
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
Reduce overhead of monitor pipeline #5
Conversation
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.
LGTM
const stream = streams[0]; | ||
|
||
if (streams.length === 1) { | ||
finished(stream, onFinished); |
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.
Nice, didn't know about the finished()
helper!
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.
OMG, finally it's provided out-of-the-box
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.
Oops, missed the test failure
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.
Considering that @hapi/good
is EOL on 31.12.2020, I'm okay with this divergence from the upstream. I created elastic/kibana#82240 to remove the dependency on @hapi/good
package.
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.
LGTM
@spalger my latest commit only fixed part of the CI issue. There's still some failures. However, it looks like |
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.
LGTM, thanks again for fixing CI!
This PR optimizes two things:
Use
pipeline
overpumpify
This is mainly to fix an "issue" with Node.js 14 where
pumpify
requires a few extra ticks every time someone writes to the pipeline. This could result in the process crashing prior to the logger writing to its destination. For example, in the following example, thedata
event-listener would never be called before the process crashes because of the thrown error on Node.js 14:However, the following would call the
data
event-listener on Node.js 14:Don't use pipeline if not required
In the case where there's only one stream, there's no need to use a pipeline. Instead we can just write directly to the stream. This also reduces the overhead of the logger slightly.