X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2Futils.js;h=5880c6c90409e08ff67febde7fbbe9a22e82d41a;hb=656ea8f70e848b03c0b668584dd533d72b376498;hp=4aa1fc55e1da6397c475e0d3b6ee5a38946efbf7;hpb=0b69752270f1ceea06a29872b3db23660a55d6d3;p=github%2FChocobozzz%2FPeerTube.git diff --git a/src/utils.js b/src/utils.js index 4aa1fc55e..5880c6c90 100644 --- a/src/utils.js +++ b/src/utils.js @@ -10,6 +10,7 @@ var replay = require('request-replay') var ursa = require('ursa') + var constants = require('./constants') var logger = require('./logger') var utils = {} @@ -30,16 +31,14 @@ } } - logger.debug('Sending informations to %s.', to_pod.url, { params: params }) - // Default 10 but in tests we want to be faster - var retries = utils.isTestInstance() ? 2 : 10 + logger.debug('Make retry requests to %s.', to_pod.url) replay( request.post(params, function (err, response, body) { callbackEach(err, response, body, params.url, to_pod) }), { - retries: retries, + retries: constants.REQUEST_RETRIES, factor: 3, maxTimeout: Infinity, errorCodes: [ 'EADDRINFO', 'ETIMEDOUT', 'ECONNRESET', 'ESOCKETTIMEDOUT', 'ENOTFOUND', 'ECONNREFUSED' ] @@ -84,8 +83,6 @@ // Add data with POST requst ? if (all_data.method === 'POST' && all_data.data) { - logger.debug('Make a POST request.') - // Encrypt data ? if (all_data.encrypt === true) { var crt = ursa.createPublicKey(pod.publicKey) @@ -109,7 +106,6 @@ makeRetryRequest(params, url, pod, signature, callbackEachRetryRequest) } } else { - logger.debug('Make a GET/DELETE request') makeRetryRequest(params, url, pod, signature, callbackEachRetryRequest) } }, callback) @@ -198,9 +194,5 @@ process.kill(-webtorrent_process.pid) } - utils.isTestInstance = function () { - return (process.env.NODE_ENV === 'test') - } - module.exports = utils })()