Crash in feed.js on_timeout
haberc opened this issue · comments
I am using nano to follow a cloudant db and my code crashes repeatedly in the follow module.
File: lib/feed.js
This line of code causes the error. Seems like self.pending.request is null.
self.emit('timeout', {elapsed_ms:elapsed_ms, heartbeat:self.heartbeat, id:self.pending.request.id()});
TypeError: Cannot call method 'id' of null
at Feed.on_timeout (C:\workspace\myApp\node_modules\nano\node_modules\follow\lib\feed.js:46
3:98)
Could this be caused by wrong usage or is it a bug within the follow module?
@jcrugzz it interestingly works very well with Cloudant already. Actually I am using nano to interact with my cloudant db and nano itself uses follow as a module.
https://cloudant.com/blog/using-cloudant-with-node-js
I have made a quick fix, just to see where it takes me. So far I am happy with it.
I changed:
self.emit('timeout', {elapsed_ms:elapsed_ms, heartbeat:self.heartbeat, id:self.pending.request.id()});
To:
if (self.pending.request != null){
self.emit('timeout', {elapsed_ms:elapsed_ms, heartbeat:self.heartbeat, id:self.pending.request.id()});
} else {
self.emit('timeout', {elapsed_ms:elapsed_ms, heartbeat:self.heartbeat, id:""});
}
I assume this will also affect CouchDB 2.0 (which inherits non-numeric sequence numbers from BigCouch)?
I forked into https://github.com/voortwis/follow and added a couple of changes to support the array type of sequence response from bigcouch and using the second value as the 'since' value. I did not get to testing it properly, if any of you want to take a look and comment on it that would be nice.
@voortwis could you fix your editior configuration so i can actually see the changes that you made in git? All I'm seeing his tab conversion churn so its hard to pick out what you actually changed. Trying to be consistent with whatever style/file format exists :).
Okay, that was indeed ugly, (ignore whitespace in my editor switched on so I didn't notice).
I committed the original version and applied the changes again.