Skip to content
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

Rotating-file stream prevent process from exiting. #97

Merged
merged 1 commit into from
Jun 1, 2014

Conversation

chakrit
Copy link
Contributor

@chakrit chakrit commented Aug 21, 2013

Related: #73

If I bunyan.createLogger with a type: "rotating-file", my process will not exits.

I've tried the solution in #73 but it does not work and my CLI program stays running even though it doesn't do anything.

Removing the rotating-file logger causes my very trivial program to exit cleanly.

Is there a way to force the logger to close all streams?

This is also very problematic in tests as having a component using the rotating-file logger means the test will not cleanup properly or the test runner may not exit and hangs the CI :/

@chakrit
Copy link
Contributor Author

chakrit commented Aug 20, 2013

Test case: https://gist.github.com/chakrit/6280041

  • $ node ok.js -- Process exits.
  • $ node not-ok.js -- Process stays running.

@chakrit chakrit closed this Aug 20, 2013
@chakrit chakrit reopened this Aug 20, 2013
@chakrit
Copy link
Contributor Author

chakrit commented Aug 20, 2013

whoops, hit the wrong button, sry.

The rotation `setTimeout` from `RotatingFileStream` will prevent the process from exiting.
This fix simply `unref()` the timeout immediately after it is set.
@chakrit
Copy link
Contributor Author

chakrit commented Aug 21, 2013

Found the solution, turns out it is simply because of the rotation setTimeout. Simply unref()-ing it fixes the problem.

Possibly also fix #73 as well but I havn't tested.

@chakrit
Copy link
Contributor Author

chakrit commented Nov 4, 2013

@trentm any chance of this getting merged anytime soon?

glenn-murray-bse pushed a commit to ascom-au/node-bunyan that referenced this pull request Mar 4, 2014
Will fail if any timers or callbacks remain registered when
instantiating a logger with a rotating file.
glenn-murray-bse pushed a commit to ascom-au/node-bunyan that referenced this pull request Mar 4, 2014
glenn-murray-bse pushed a commit to ascom-au/node-bunyan that referenced this pull request Mar 4, 2014
hajoeichler added a commit to sphereio/sphere-stock-sync that referenced this pull request Mar 11, 2014
hajoeichler added a commit to sphereio/sphere-order-distribution that referenced this pull request Mar 11, 2014
@trentm trentm merged commit 9036035 into trentm:master Jun 1, 2014
@trentm
Copy link
Owner

trentm commented Jun 1, 2014

Thanks very much for finding the root issue here. I apologize for taking so long to get to this. This will be in bunyan 0.23.1.

@trentm
Copy link
Owner

trentm commented Jun 1, 2014

Hrm, the unref addition in the PR only fixes this for node 0.10. Node 0.8.x doesn't have unref on setTimeout results. I'll add a warning about rotating-file support for node 0.8.

@chakrit
Copy link
Contributor Author

chakrit commented Jun 1, 2014

wow, that's a very long time! anyway glad it's finally fixed for good : )

awesome library btw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants