Skip to content

Commit

Permalink
Merge pull request #70 from redgeoff/timeout-reconnect
Browse files Browse the repository at this point in the history
fix(enhanced-request): reconnect on timeout
  • Loading branch information
redgeoff authored Jan 19, 2018
2 parents 776d77e + 6e201bc commit 174c95c
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions scripts/enhanced-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,30 +178,29 @@ 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',
'ETIMEDOUT',
'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);
}
};
Expand Down

0 comments on commit 174c95c

Please sign in to comment.