mibes / couch-rs

CouchDB library for Rust
Apache License 2.0
59 stars 17 forks source link

allow to disable reqwest timeout #14

Closed sify21 closed 3 years ago

sify21 commented 3 years ago

When using this library to follow npm registry changes, I often come across this error:

Error: 501 Not Implemented: error sending request for url (https://replicate.npmjs.com/_changes?include_docs=true&since=827187&timeout=60000&feed=continuous): operation timed out

The reason for this timeout may be a local network congestion, or the npm registry just responds slower. This error is triggered during ChangesStreamState::Requesting state, so despite that I'm using infinite mode, the program will exit, and I need to restart it after about half a hour.

There is another situation: replicate.npmjs.com may contain a big change entry, I've seen one which is 64MB. It took quite a while for me using curl to fetch this single entry, default timeout is not enough. In this case, the timeout error is triggered during ChangesStreamState::Reading state, and bacause of the test below, the program will get stuck in an infinite loop. https://github.com/mibes/couch-rs/blob/c39b09fa667e513e456f6394584d754dffc1eacd/couch_rs/src/changes.rs#L142

I tested the program locally with timeout disabled, it has been running continuously for more than 2 hour without breaks.

horacimacias commented 3 years ago

looks good, thanks!