apache/couchdb — pull request #60 by unclespode (2013-05-17 11:17:44+00:00)
Title: Update jquery.couch.js

In the original code, if there was an error doing the long poll, it would wait 100ms and then try again. If it errors again, it doubles to 200ms. If it errors again, it doubles again etc. with no cap.

This means after 10 errors in a row, you will be in a position of waiting a minute and a half before it attempts to reconnect. After that, 3 minutes and then it frankly spirals out of control!

That means if you lose internet connectivity (entirely possible if your wireless/3g is flakey) - you will very quickly, essentially lose your polling abilities.

My suggestion is to put a cap on this timeout - I've simply added in a conditional so that it will never go above 5 seconds. In my own use case, I'm actually going to keep it at 100ms and not multiply, so it might be worth having this as an option instead of hard coded.