diff --git a/CHANGES.md b/CHANGES.md index 51f4b1d..1320984 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,7 +10,8 @@ Known issues: - [pull #125, pull #97, issue #73] Unref rotating-file timeout which was preventing processes from exiting (by https://github.com/chakrit and - https://github.com/glenn-murray-bse). + https://github.com/glenn-murray-bse). Note: this only fixes the issue + for node 0.10 and above. ## bunyan 0.23.0 diff --git a/README.md b/README.md index fb52d54..ed261f3 100644 --- a/README.md +++ b/README.md @@ -643,6 +643,14 @@ used for anything else. ## stream type: `rotating-file` +**WARNING:** Users of Bunyan's `rotating-file` should (a) be using at least +bunyan 0.23.1 (with the fix for [this +issue](https://github.com/trentm/node-bunyan/pull/97)), and (b) should use at +least node 0.10 (node 0.8 does not support the `unref()` method on +`setTimeout(...)` needed for the mentioned fix). The symptom is that process +termination will hang for up to a full rotation period. + + A `type === 'rotating-file'` is a file stream that handles file automatic rotation. diff --git a/test/process-exit.test.js b/test/process-exit.test.js index 5d480df..85ade83 100644 --- a/test/process-exit.test.js +++ b/test/process-exit.test.js @@ -1,6 +1,10 @@ 'use strict'; /* - * Test that bunyan process will terminate + * Test that bunyan process will terminate. + * + * Note: Currently (bunyan 0.23.1) this fails on node 0.8, because there is + * no `unref` in node 0.8 and bunyan doesn't yet have `Logger.prototype.close()` + * support. */ var exec = require('child_process').exec; @@ -11,12 +15,18 @@ if (require.cache[__dirname + '/tap4nodeunit.js']) var tap4nodeunit = require('./tap4nodeunit.js'); var test = tap4nodeunit.test; -test('log with rotating file stream will terminate gracefully', function (t) { - exec('node ' +__dirname + '/process-exit.js', {timeout: 1000}, - function (err, stdout, stderr) { - t.ifError(err); - t.equal(stdout, 'done\n'); - t.equal(stderr, ''); - t.end(); +var nodeVer = process.versions.node.split('.').map(Number); + +if (nodeVer[0] <= 0 && nodeVer[1] <= 8) { + console.warn('skip test (node <= 0.8)'); +} else { + test('log with rotating file stream will terminate gracefully', function (t) { + exec('node ' +__dirname + '/process-exit.js', {timeout: 1000}, + function (err, stdout, stderr) { + t.ifError(err); + t.equal(stdout, 'done\n'); + t.equal(stderr, ''); + t.end(); + }); }); -}); +}