Skip to content

Commit

Permalink
Trying to work with #43 but it's throwing the stream error instead
Browse files Browse the repository at this point in the history
  • Loading branch information
jhs committed Jan 3, 2014
1 parent fe59144 commit d0447fc
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/feed.js
Expand Up @@ -618,7 +618,9 @@ function destroy_req(req) {
if(req)
destroy_response(req.response)

if(req && typeof req.destroy == 'function')
if(req && typeof req.abort == 'function')
req.abort()
else if(req && typeof req.destroy == 'function')
req.destroy()
}

Expand Down
34 changes: 34 additions & 0 deletions test/issues/43.js
@@ -0,0 +1,34 @@
var tap = require('tap')
var test = tap.test
var util = require('util')

var lib = require('../../lib')
var couch = require('../couch')
var follow = require('../../api')

couch.setup(test)

test('Issue #43', function(t) {
var changes = 0

var feed = follow({'db':couch.DB, 'inactivity_ms':couch.rtt()*3}, on_change)
feed.on('stop', on_stop)
feed.on('error', on_err)

function on_err(er) {
t.false(er, 'Error event should never fire')
t.end()
}

function on_change(er, change) {
console.error('Change: ' + JSON.stringify(change))
changes += 1
this.stop()
}

function on_stop(er) {
t.false(er, 'No problem stopping')
t.equal(changes, 1, 'Only one change seen since stop was called in its callback')
t.end()
}
})

0 comments on commit d0447fc

Please sign in to comment.