Skip to content

Commit

Permalink
revised the retrystrategy
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-jy committed Nov 2, 2023
1 parent 6cc2fda commit b1be52e
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
18 changes: 9 additions & 9 deletions lib/connection/connection_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const DEFAULT_PARAMS =
'forceStageBindError',
'includeRetryReason',
'disableQueryContextCache',
'loginTimeout',
'retryTimeout',
];
const Logger = require('../logger');

Expand Down Expand Up @@ -485,12 +485,12 @@ function ConnectionConfig(options, validateCredentials, qaMode, clientInfo)
disableQueryContextCache = options.disableQueryContextCache;
}

let loginTimeout = 300;
if (Util.exists(options.loginTimeout)) {
Errors.checkArgumentValid(Util.isNumber(options.loginTimeout),
ErrorCodes.ERR_CONN_CREATE_INVALID_MAX_LOGIN_TIMEOUT);
let retryTimeout = 300;
if (Util.exists(options.retryTimeout)) {
Errors.checkArgumentValid(Util.isNumber(options.retryTimeout),
ErrorCodes.ERR_CONN_CREATE_INVALID_MAX_RETRY_TIMEOUT);

loginTimeout = Math.max(loginTimeout,options.loginTimeout);
retryTimeout = Math.max(retryTimeout,options.retryTimeout);
}

if (validateDefaultParameters)
Expand Down Expand Up @@ -808,8 +808,8 @@ function ConnectionConfig(options, validateCredentials, qaMode, clientInfo)
*
* @returns {Number}
*/
this.getLoginTimeout = function () {
return loginTimeout;
this.getRetryTimeout = function () {
return retryTimeout;
}

// save config options
Expand Down Expand Up @@ -978,7 +978,7 @@ function createParameters()
},
{
name: PARAM_RETRY_SF_STARTING_SLEEP_TIME,
defaultValue: 4,
defaultValue: 1,
validate: isNonNegativeNumber
},
{
Expand Down
2 changes: 1 addition & 1 deletion lib/constants/error_messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ exports[404040] = 'Invalid browser timeout value. The specified value must be a
exports[404041] = 'Invalid disablQueryContextCache. The specified value must be a boolean.';
exports[404042] = 'Invalid includeRetryReason. The specified value must be a boolean.'
exports[404043] = 'Invalid clientConfigFile value. The specified value must be a string.';
exports[404044] = 'Invalid loginTimeout value. The specified value must be a number.';
exports[404044] = 'Invalid retryTimeout value. The specified value must be a number.';

// 405001
exports[405001] = 'Invalid callback. The specified value must be a function.';
Expand Down
2 changes: 1 addition & 1 deletion lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ codes.ERR_CONN_CREATE_INVALID_BROWSER_TIMEOUT = 404040;
codes.ERR_CONN_CREATE_INVALID_DISABLED_QUERY_CONTEXT_CACHE = 404041
codes.ERR_CONN_CREATE_INVALID_INCLUDE_RETRY_REASON =404042
codes.ERR_CONN_CREATE_INVALID_CLIENT_CONFIG_FILE = 404043;
codes.ERR_CONN_CREATE_INVALID_LOGIN_TIMEOUT = 404044;
codes.ERR_CONN_CREATE_INVALID_RETRY_TIMEOUT = 404044;

// 405001
codes.ERR_CONN_CONNECT_INVALID_CALLBACK = 405001;
Expand Down
4 changes: 2 additions & 2 deletions lib/services/sf.js
Original file line number Diff line number Diff line change
Expand Up @@ -1179,10 +1179,10 @@ StateConnecting.prototype.continue = function ()
const startTime = connectionConfig.accessUrl.startsWith('https://') ?
Date.now() : 'FIXEDTIMESTAMP';
const maxLoginRetries = connectionConfig.getRetrySfMaxLoginRetries();
const maxLoginTimeout = connectionConfig.getLoginTimeout();
const maxLoginTimeout = connectionConfig.getRetryTimeout();
let sleep = connectionConfig.getRetrySfStartingSleepTime();;
let totalTimeout = sleep;
Logger.getInstance().debug("Total loginTimeout is for the retries = " + maxLoginTimeout);
Logger.getInstance().debug("Total retryTimeout is for the retries = " + maxLoginTimeout);
const parent = this;
const requestCallback = function (err, body)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ exports.getNextSleepTime = getNextSleepTime;
* @returns {Boolean} true if it is loginRequest, otherwise false.
*/
exports.isLoginRequest = function (loginUrl) {
const endPoints = ['/v1/login-request', '/authenticator-request'];
const endPoints = ['/v1/login-request', '/authenticator-request',];
return endPoints.some((endPoint) => loginUrl.includes(endPoint));
}

Expand Down
8 changes: 4 additions & 4 deletions test/unit/connection/connection_config_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,12 +547,12 @@ describe('ConnectionConfig: basic', function ()
errorCode: ErrorCodes.ERR_CONN_CREATE_INVALID_CLIENT_CONFIG_FILE
},
{
name: 'invalid maxLoginTimeout',
name: 'invalid retryTimeout',
options: {
account: 'account',
username: 'username',
password: 'password',
loginTimeout: 'invalud'
retryTimeout: 'invalud'
},
errorCode: ErrorCodes.ERR_CONN_CREATE_INVALID_MAX_LOGIN_TIMEOUT
},
Expand Down Expand Up @@ -925,13 +925,13 @@ describe('ConnectionConfig: basic', function ()
}
},
{
name: 'login time out',
name: 'retry time out',
input:
{
account: 'account',
username: 'username',
password: 'password',
loginTimeout: 1234,
retryTimeout: 1234,
},
options:
{
Expand Down

0 comments on commit b1be52e

Please sign in to comment.