iriscouch / follow

Very stable, very reliable, NodeJS CouchDB _changes follower
Apache License 2.0
393 stars 82 forks source link

Retry change request on last_seq #91

Closed smithsz closed 7 years ago

smithsz commented 7 years ago

CouchDB terminates the changes feed, sending a last_seq, if the node serving your request is placed in maintenance mode (see https://github.com/apache/couchdb-fabric/blob/master/src/fabric_view_changes.erl#L94). The expectation here is that the client will retry the request using the last_seq provided in the response.

Currently follow is just throwing an error here under the false assumption that the database has been deleted. This change always retries the changes request if it's terminated by the server. Only when the following retry attempt returns a 404 do we mark the database as deleted and stop the feed.