From 116d93029552dc2b85e245c653231573531a7714 Mon Sep 17 00:00:00 2001 From: Geoff Cox Date: Sun, 21 Jan 2018 07:45:58 -0800 Subject: [PATCH] fix(timeout): timeouts are fatal --- package.json | 2 +- scripts/enhanced-request.js | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index f5d8ff5..1ad397b 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "dependencies": { "backoff-promise": "^0.0.3", "bluebird": "^3.5.0", - "quelle": "^1.0.1", + "quelle": "^1.0.2", "request": "^2.81.0", "sporks": "^1.0.0", "squadron": "^0.0.4" diff --git a/scripts/enhanced-request.js b/scripts/enhanced-request.js index fe2bfac..a84c1b3 100644 --- a/scripts/enhanced-request.js +++ b/scripts/enhanced-request.js @@ -196,11 +196,19 @@ EnhancedRequest.prototype._shouldReconnect = function (err) { 'Failed to fetch', // ECONNREFUSED/ENOTFOUND in Chrome 'Type error', // ECONNREFUSED/ENOTFOUND in Safari 'XHR error', // ECONNREFUSED/ENOTFOUND in Firefox - 'EAI_AGAIN', // Transient DNS error + 'EAI_AGAIN' // Transient DNS error + // TODO: It is not clear why CouchDB responds with these timeout errors and immediately + // retrying the request often leads to deadlocks when you are continuously listening. In + // practice, it is better that your app throws a fatal error and then is restarted, e.g. via + // Docker, as this seems to reliably recover from this state. At some point we should analyze + // this better and determine where the bug lies and fix it at the root cause: + // https://github.com/redgeoff/spiegel/issues/100 + // // Occurs randomly even when there is a relatively small amount of data, e.g. "The request // could not be processed in a reasonable amount of time" - 'timeout' + // + // 'timeout' ].join('|'), 'i').test(err.message); } };