From 90360351b452a909f2d0d391a6565b94719e046d Mon Sep 17 00:00:00 2001 From: Chakrit Wichian Date: Wed, 21 Aug 2013 14:47:28 +0700 Subject: [PATCH] Fix #97 unref() the rotation timeout in RotatingFileStream. The rotation `setTimeout` from `RotatingFileStream` will prevent the process from exiting. This fix simply `unref()` the timeout immediately after it is set. --- lib/bunyan.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/bunyan.js b/lib/bunyan.js index 6eaf539e..b43e7a65 100644 --- a/lib/bunyan.js +++ b/lib/bunyan.js @@ -990,6 +990,9 @@ RotatingFileStream.prototype._setupNextRot = function () { this.timeout = setTimeout( function () { self.rotate(); }, this.rotAt - Date.now()); + if (typeof this.timeout.unref === 'function') { + this.timeout.unref(); + } } RotatingFileStream.prototype._nextRotTime = function _nextRotTime(first) {