Skip to content

Commit

Permalink
Clear the inactivity timer when dying. Closes #9
Browse files Browse the repository at this point in the history
  • Loading branch information
jhs committed Dec 15, 2011
1 parent 3caafe7 commit e7b50e2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions feed.js
Expand Up @@ -447,6 +447,12 @@ Feed.prototype.die = function(er) {
// Warn code executing later that death has occured.
self.dead = true

clearTimeout(self.inactivity_timer)
clearTimeout(self.pending.wait_timer)

self.inactivity_timer = null
self.pending.wait_timer = null

var req = self.pending.request;
self.pending.request = null;
if(req) {
Expand Down
19 changes: 19 additions & 0 deletions test/issues.js
Expand Up @@ -48,6 +48,25 @@ test('Issue #8', function(t) {
})
})

test('Issue #9', function(t) {
var timeouts = timeout_tracker()

follow({db:DB, inactivity_ms:30000}, function(er, change) {
if(change.seq == 1)
return // Let it run through once, just for fun.

t.equal(change.seq, 2, 'The second change will be the last')
this.stop()

setTimeout(check_inactivity_timer, 250)
function check_inactivity_timer() {
t.equal(timeouts().length, 0, 'No lingering timeouts after teardown: ' + tims(timeouts()))
timeouts().forEach(function(id) { clearTimeout(id) })
t.end()
}
})
})

//
// Utilities
//
Expand Down

0 comments on commit e7b50e2

Please sign in to comment.