I want to stop the follow feed once it has caught up with the database. Unfortunately, if the feed's since is the db's current seq then a _changes request is left hanging and the JS process runs indefinitely.
Here's example code that demonstrates the issue:
var follow = require("follow");
var db = process.argv[2];
var since = process.argv.length > 3 ? parseInt(process.argv[3]) : "now";
var feed = new follow.Feed({db: db, since: since});
feed.on("change", function(change) {
console.log("change:", change.seq);
});
feed.on("catchup", function() {
console.log("catchup");
feed.stop();
});
feed.on("stop", function(err) {
console.log("stop:", err);
setTimeout(function() {
var handles = process._getActiveHandles();
handles.forEach(function(handle) {
console.log("******************************");
console.log(handle);
});
console.log(handles.length);
}, 1000);
});
feed.follow();
The JS process will hang unless a value for since is provided that's older that the db's current seq. When it hangs the request to the _changes feed is visible in the dump of active handles (the timeout just gives things a bit of time to settle down).
I want to stop the follow feed once it has caught up with the database. Unfortunately, if the feed's since is the db's current seq then a _changes request is left hanging and the JS process runs indefinitely.
Here's example code that demonstrates the issue:
The JS process will hang unless a value for since is provided that's older that the db's current seq. When it hangs the request to the _changes feed is visible in the dump of active handles (the timeout just gives things a bit of time to settle down).