-
Notifications
You must be signed in to change notification settings - Fork 52
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
feat: Add optional keepAlive
option to Meter and Timer
#64
Conversation
@@ -92,7 +92,8 @@ class Reporter { | |||
* @type {Logger} | |||
* @protected | |||
*/ | |||
this._log = options.logger || consoleLogLevel({ name: 'Reporter', level: options.logLevel || 'info', prefix: prefix }); | |||
this._log = | |||
options.logger || consoleLogLevel({ name: 'Reporter', level: options.logLevel || 'info', prefix: prefix }); |
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.
Prettier made this change.
Pull Request Test Coverage Report for Build 374
💛 - Coveralls |
@@ -22,6 +22,10 @@ class Meter { | |||
constructor(properties) { | |||
this._properties = properties || {}; | |||
this._initializeState(); | |||
|
|||
if (!this._properties.keepAlive) { |
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.
What are the consequences of making this the default behavior rather than inverting this logic?
Is this a breaking change for people?
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 mean having the default be false.
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.
In an application or process that has any kind of active handle (e.g. listening on a port, other timer etc) that'll keep the event loop alive anyway.
If measured-core is used in one-off jobs or similar then this behavior usually causes issues and keeps the process hanging.
I see it as highly unlikely to be breaking.
If you see this as a problem I can certainly unpublish 1.43.0 and release this as a major but to me this very much is a minor.
This PR unrefs timers by default, eliminating headaches for people unsure about why their unit tests keep hanging.
It also eliminates having to break a 1 line piece of code into 3:
I've set the default to
false
since that was most helpful for my team. However, I could be convinced to have it default totrue
.