lib/send.js
function maybeRetry(err, IOD, IODOpts, apiType, callback) {
	var retryApiReq = apiType !== IOD.TYPES.SYNC &&
		apiType !== IOD.TYPES.RESULT &&
		apiType !== IOD.TYPES.DISCOVERY

	if (IODOpts.retries == null || retryApiReq) callback(err)
	else if (!--IODOpts.retries) callback(err)
	var reqTypeDontRetry =  apiType !== IOD.TYPES.SYNC &&
		apiType !== IOD.TYPES.DISCOVERY &&
		apiType !== IOD.TYPES.RESULT

	if (IODOpts.retries == null || reqTypeDontRetry) callback(err)
	else if (!IODOpts.retries--) callback(err)
	else {
		var errCode = err.error
		var errCodeList = T.maybeToArray(IODOpts.errorCodes)

		// Backend request failed or timed out
		if (errCode === 5000 || errCode === 7000 || _.contains(errCodeList, errCode)) {
			exports.send(IOD, IODOpts, apiType, callback)
		}
		else callback(err)
	}
}
function maybeRetry(err, IOD, IODOpts, apiType, callback) {
	var retryApiReq = apiType !== IOD.TYPES.SYNC &&
		apiType !== IOD.TYPES.RESULT &&
		apiType !== IOD.TYPES.DISCOVERY

	if (IODOpts.retries == null || retryApiReq) callback(err)
	else if (!--IODOpts.retries) callback(err)
	var reqTypeDontRetry =  apiType !== IOD.TYPES.SYNC &&
		apiType !== IOD.TYPES.DISCOVERY &&
		apiType !== IOD.TYPES.RESULT

	if (IODOpts.retries == null || reqTypeDontRetry) callback(err)
	else if (!IODOpts.retries--) callback(err)
	else {
		var errCode = err.error
		var errCodeList = T.maybeToArray(IODOpts.errorCodes)

		// Backend request failed or timed out
		if (errCode === 5000 || errCode === 7000 || _.contains(errCodeList, errCode)) {
			exports.send(IOD, IODOpts, apiType, callback)
		}
		else callback(err)
	}
}
function maybeRetry ( err , IOD , IODOpts , apiType , callback ) { var retryApiReq = apiType !== IOD . TYPES . SYNC && apiType !== IOD . TYPES . RESULT && apiType !== IOD . TYPES . DISCOVERY if ( IODOpts . retries == null || retryApiReq ) callback ( err ) else if ( ! -- IODOpts . retries ) callback ( err ) var reqTypeDontRetry = apiType !== IOD . TYPES . SYNC && apiType !== IOD . TYPES . DISCOVERY && apiType !== IOD . TYPES . RESULT if ( IODOpts . retries == null || reqTypeDontRetry ) callback ( err ) else if ( ! IODOpts . retries -- ) callback ( err ) else { var errCode = err . error var errCodeList = T . maybeToArray ( IODOpts . errorCodes ) // Backend request failed or timed out if ( errCode === 5000 || errCode === 7000 || _ . contains ( errCodeList , errCode ) ) { exports . send ( IOD , IODOpts , apiType , callback ) } else callback ( err ) } }
If retries is specified on `IODOpts` and is greater than one,
retry request if it is either a Backend failure or time out.

@param {*} err - Error
@param {IOD} IOD - IOD object
@param {Object} IODOpts - IOD options
@param {String} apiType - Api type
@param {Function} callback - callback(err | res)
If retries is specified on IODOpts and is greater than one retry request if it is either a Backend failure or time out .