From 43e8442e73a0893cc667a32c146cab1f41dd7406 Mon Sep 17 00:00:00 2001 From: sfc-gh-ext-simba-jy Date: Fri, 20 Oct 2023 11:24:12 -0700 Subject: [PATCH] Removed spaces and formatted code --- lib/services/sf.js | 4 ---- lib/util.js | 4 +--- test/unit/util_test.js | 13 +++++++------ 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/services/sf.js b/lib/services/sf.js index bcec47fac..2f55c0390 100644 --- a/lib/services/sf.js +++ b/lib/services/sf.js @@ -787,7 +787,6 @@ function StateAbstract(options) "CLIENT_APP_VERSION": requestOptions.json.data.CLIENT_APP_VERSION, "CLIENT_APP_ID": requestOptions.json.data.CLIENT_APP_ID, }) - } // augment the options with the absolute url @@ -1182,7 +1181,6 @@ StateConnecting.prototype.continue = function () const maxLoginRetries = connectionConfig.getRetrySfMaxLoginRetries(); let sleep = connectionConfig.getRetrySfStartingSleepTime(); const cap = connectionConfig.getRetrySfMaxSleepTime(); - // const isLoginRequest = Logger.getInstance().debug("Retry Max sleep time = " + cap); const parent = this; const requestCallback = function (err, body) @@ -1216,9 +1214,7 @@ StateConnecting.prototype.continue = function () isRetryableNetworkError(err) || isRetryableHttpError(err))) { numRetries++; - // sleep = Util.nextSleepTime(1, cap, sleep); sleep = Util.jitteredSleepTime(numRetries, sleep, cap); - console.log(sleep); setTimeout(sendRequest, sleep * 1000); return; } diff --git a/lib/util.js b/lib/util.js index 21cebd904..29d6a1a82 100644 --- a/lib/util.js +++ b/lib/util.js @@ -405,8 +405,7 @@ exports.isNode = function () /** * Returns the next sleep time calculated by exponential backoff with * decorrelated jitter. - * sleep = min(cap, random_between(base, sleep * 3)) - * + * sleep = min(cap, random_between(base, sleep * 3)) * for more details, check out: * http://www.awsarchitectureblog.com/2015/03/backoff.html * @param base minimum seconds @@ -454,7 +453,6 @@ function getJitter (curWaitTime) { * @param {Number} secondNumber * @returns {Boolean} return one of the argument randomly. */ - function chooseRandom (firstNumber, secondNumber) { const random = Math.floor(Math.random() * 1000); return random % 2 === 0 ? firstNumber : secondNumber; diff --git a/test/unit/util_test.js b/test/unit/util_test.js index a12d4aef6..70000555d 100644 --- a/test/unit/util_test.js +++ b/test/unit/util_test.js @@ -520,7 +520,7 @@ describe('Util', function () assert.strictEqual(url, testCase.result); }) } - }) + }); it("Util.isLoginRequest Test", function () { const baseUrl = 'wwww.test.com'; @@ -549,14 +549,15 @@ describe('Util', function () { endPoint: '/tokenRequest', result:false, - } + }, ]; + for (const {endPoint,result} of testCases) { - const isLoginRequest = Util.isLoginRequest(baseUrl+endPoint); - assert.strictEqual(isLoginRequest,result); + const isLoginRequest = Util.isLoginRequest(baseUrl + endPoint); + assert.strictEqual(isLoginRequest, result); } - }) + }); it("Util.jitterSleepTime Test", function () { const maxSleepTime = 16; @@ -567,7 +568,7 @@ describe('Util', function () const nextSleep = 2 ** numRetries; assert.ok(result === nextSleep + jitter || result === nextSleep - jitter) - }) + }); it('Util.apply()', function () {