Skip to content

Commit 2be1e28

Browse files
SNOW-1944643 - network error retries
1 parent 9f81cb4 commit 2be1e28

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

lib/connection/statement.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1492,7 +1492,9 @@ function sendSfRequest(statementContext, options, appendQueryParamOnRetry) {
14921492
// if we haven't exceeded the maximum number of retries yet and the server
14931493
// came back with a retryable error code
14941494
if (numRetries < maxNumRetries &&
1495-
err && (Util.isRetryableHttpError(err.response, false) || Util.isNetworkError(err))
1495+
err && (!err.response || (Util.isRetryableHttpError(err.response, false))
1496+
// || Util.isNetworkError(err)
1497+
)
14961498
) {
14971499
// increment the retry count
14981500
numRetries++;

lib/util.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,11 +380,7 @@ export function isRetryableHttpError(response: any, retry403: boolean) {
380380
(response.statusCode === 429));
381381
};
382382

383-
exports.isNetworkError = function (err) {
384-
return err.code === Errors.codes.ERR_SF_NETWORK_COULD_NOT_CONNECT;
385-
};
386-
387-
exports.validateClientSessionKeepAliveHeartbeatFrequency = function (input, masterValidity) {
383+
export function validateClientSessionKeepAliveHeartbeatFrequency(input: number, masterValidity: number) {
388384
let heartbeatFrequency = input;
389385
const realMax = Math.floor(masterValidity / 4);
390386
const realMin = Math.floor(realMax / 4);

test/integration/testConnectionRetries.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ describe('Connection test', function () {
3232

3333
it('Test retries after connection reset - success', async function () {
3434
await addWireMockMappingsFromFile(wireMock, 'wiremock/mappings/six_reset_connection_and_correct_response.json');
35-
const connectionOption = { ...connParameters.wiremock, password: 'MOCK_TOKEN', port: port, sfRetryMaxSleepTime: 2 };
35+
const connectionOption = { ...connParameters.wiremock, password: 'MOCK_TOKEN', port: port, sfRetryMaxSleepTime: 2, sfRetryMaxNumRetries: 10 };
3636
const connection = testUtil.createConnection(connectionOption);
3737
await testUtil.connectAsync(connection);
3838
await assert.doesNotReject(async () => await testUtil.executeCmdAsync(connection, ' Select 1'));
3939
});
4040

41-
it('Test retries after alformed response', async function () {
41+
it('Test retries after malformed response', async function () {
4242
await addWireMockMappingsFromFile(wireMock, 'wiremock/mappings/six_malformed_and_correct.json');
4343
const connectionOption = { ...connParameters.wiremock, password: 'MOCK_TOKEN', port: port, sfRetryMaxSleepTime: 2 };
4444
const connection = testUtil.createConnection(connectionOption);

0 commit comments

Comments
 (0)