Proposal: inactivity_ms does not perform as expected/documented, let's fix that.
grimborg opened this issue · comments
According to the documentation, when providing a value for inactivity_ms
, "If no changes happen by the timeout, Follow will signal an error." But it actually calls on_inactivity
, which restarts the feed (see https://github.com/iriscouch/follow/blob/master/lib/feed.js#L624-L637).
In some cases it is not desirable to automatically retry the feed. In my case, for example, I have a large number of databases which I want to stop following once they have been inactive for a while.
Furthemore, the documented behaviour (emiting an error) seems somewhat confusing: the fact that there haven't been changes on a database should not be an error.
Instead, I would propose the following:
- Emit a
'timeout'
signal when the timeout expires. - Add a setting
retry_after_timeout
(defaulttrue
), which determines whether the feed should be retried after a timeout.
This would allow users to indicate what they want Follow to do when there is a timeout, without breaking backwards compatibility.
If you are okay with this proposal, I'll implement it and send a PR.
@grimborg thanks for bringing this up. I made this change a while ago when I felt the erroring could be a bit too aggressive since its not a fatal
case. The changes you suggested seem reasonable, I would just make it an inactive
event rather than a timeout
event. There is already a timeout
event that has different semantics currently.
Thanks for the feedback! I'll emit an inactive
event as you propose.