mirror of
https://github.com/donl/slouch.git
synced 2026-06-03 06:12:37 -06:00
fix(enhanced-request): reconnect on timeout
This commit is contained in:
parent
776d77e6bf
commit
6e201bcf62
1 changed files with 10 additions and 11 deletions
|
|
@ -178,19 +178,13 @@ EnhancedRequest.prototype._shouldReconnect = function (err) {
|
|||
return true;
|
||||
|
||||
default:
|
||||
|
||||
// - ECONNREFUSED => Connection refused, e.g. because the CouchDB server is being restarted.
|
||||
// - Occurs randomly when many simultaenous connections:
|
||||
// - emfile
|
||||
// - socket hang up
|
||||
// - ECONNRESET
|
||||
// - ETIMEDOUT
|
||||
// - function_clause (CouchDB 2)
|
||||
// - unknown_error (CouchDB 2)
|
||||
// - internal_server_error (CouchDB 2)
|
||||
return new RegExp([
|
||||
// Connection refused, e.g. because the CouchDB server is being restarted.
|
||||
'ECONNREFUSED',
|
||||
|
||||
'ENETUNREACH', // can occur when box sleeps/wakes-up
|
||||
|
||||
// Occurs randomly when many simultaenous connections:
|
||||
'emfile',
|
||||
'socket hang up',
|
||||
'ECONNRESET',
|
||||
|
|
@ -198,10 +192,15 @@ EnhancedRequest.prototype._shouldReconnect = function (err) {
|
|||
'function_clause',
|
||||
'unknown_error',
|
||||
'internal_server_error',
|
||||
|
||||
'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
|
||||
|
||||
// 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'
|
||||
].join('|'), 'i').test(err.message);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue