Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feed that starts at "now" cannot be stopped #46

Open
atomatt opened this issue Apr 4, 2014 · 0 comments
Open

Feed that starts at "now" cannot be stopped #46

atomatt opened this issue Apr 4, 2014 · 0 comments

Comments

@atomatt
Copy link

atomatt commented Apr 4, 2014

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant