benoitc / couchbeam

Apache CouchDB client in Erlang
Other
242 stars 114 forks source link

Streaming changes timeout after 10 seconds when "since=now" and no changes occur within 10 seconds #173

Open jordan0day opened 7 years ago

jordan0day commented 7 years ago

On couchbeam 1.4.2 and CouchDB 2.0, when setting up a changes stream (either using gen_changes or by hand), it looks like couchbeam_changes_stream will wait at most 10 seconds before exiting with timeout (see https://github.com/benoitc/couchbeam/blob/1.4.2/src/couchbeam_changes_stream.erl#L150, TIMEOUT is defined as 10000).

This is really just an issue when using since=now in the changes feed, and no documents change within 10 seconds. If using some previous since value, it's okay, because couchdb sends an immediate response.

I'm curious if it would make sense here to look at the included options (either heartbeat or timeout) and use that value instead of the hard-coded 10000 ms? Obviously I can set heartbeat to 9000ms or so and everything will be fine, but it seems like a longer heartbeat should be allowable? Or is there a reason we should timeout at 10 seconds.