Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: add test for a unref'ed timer leak
  • Loading branch information
indutny committed Apr 3, 2015
commit ca615ac4f3d382df6fc10c6dec73523dda324eec
25 changes: 25 additions & 0 deletions test/parallel/test-timers-unref-leak.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var assert = require('assert');

var called = 0;
var closed = 0;

var timeout = setTimeout(function() {
called++;
}, 10);
timeout.unref();

// Wrap `close` method to check if the handle was closed
var close = timeout._handle.close;
timeout._handle.close = function() {
closed++;
return close.apply(this, arguments);
};

// Just to keep process alive and let previous timer's handle die
setTimeout(function() {
}, 50);

process.on('exit', function() {
assert.equal(called, 1);
assert.equal(closed, 1);
});