Skip to content

Commit 791ae32

Browse files
committed
chore: constant for retry delay during binary start
1 parent 7ef8681 commit 791ae32

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

setup-local/config/constants.js

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ module.exports = {
5050
},
5151

5252
BINARY_MAX_TRIES: 3,
53+
RETRY_DELAY_BINARY: 5000,
5354

5455
RESTRICTED_LOCAL_ARGS: ['k', 'key', 'local-identifier', 'daemon', 'only-automate', 'verbose', 'log-file', 'ci-plugin'],
5556

setup-local/dist/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,7 @@ const {
10831083
LOCAL_BINARY_ZIP,
10841084
LOCAL_LOG_FILE_PREFIX,
10851085
LOCAL_BINARY_TRIGGER,
1086+
RETRY_DELAY_BINARY,
10861087
BINARY_MAX_TRIES,
10871088
ALLOWED_INPUT_VALUES: {
10881089
LOCAL_TESTING,
@@ -1286,7 +1287,7 @@ class BinaryControl {
12861287
if (triesAvailable) {
12871288
core.info(`Error in starting local tunnel: ${e.message}. Trying again in 5 seconds...`);
12881289
// eslint-disable-next-line no-await-in-loop
1289-
await Utils.sleepFor(5000);
1290+
await Utils.sleepFor(RETRY_DELAY_BINARY);
12901291
} else {
12911292
throw Error(`Local tunnel could not be started. Error message from binary: ${e.message}`);
12921293
}
@@ -13489,6 +13490,7 @@ module.exports = {
1348913490
},
1349013491

1349113492
BINARY_MAX_TRIES: 3,
13493+
RETRY_DELAY_BINARY: 5000,
1349213494

1349313495
RESTRICTED_LOCAL_ARGS: ['k', 'key', 'local-identifier', 'daemon', 'only-automate', 'verbose', 'log-file', 'ci-plugin'],
1349413496

setup-local/src/binaryControl.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const {
1818
LOCAL_BINARY_ZIP,
1919
LOCAL_LOG_FILE_PREFIX,
2020
LOCAL_BINARY_TRIGGER,
21+
RETRY_DELAY_BINARY,
2122
BINARY_MAX_TRIES,
2223
ALLOWED_INPUT_VALUES: {
2324
LOCAL_TESTING,
@@ -221,7 +222,7 @@ class BinaryControl {
221222
if (triesAvailable) {
222223
core.info(`Error in starting local tunnel: ${e.message}. Trying again in 5 seconds...`);
223224
// eslint-disable-next-line no-await-in-loop
224-
await Utils.sleepFor(5000);
225+
await Utils.sleepFor(RETRY_DELAY_BINARY);
225226
} else {
226227
throw Error(`Local tunnel could not be started. Error message from binary: ${e.message}`);
227228
}

setup-local/test/binaryControl.test.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const {
2121
LOCAL_BINARY_ZIP,
2222
LOCAL_LOG_FILE_PREFIX,
2323
LOCAL_BINARY_TRIGGER,
24+
RETRY_DELAY_BINARY,
2425
ALLOWED_INPUT_VALUES: {
2526
LOCAL_TESTING,
2627
},
@@ -509,7 +510,7 @@ describe('Binary Control Operations', () => {
509510
try {
510511
await binaryControl.startBinary();
511512
} catch (e) {
512-
sinon.assert.calledWith(Utils.sleepFor, 5000);
513+
sinon.assert.calledWith(Utils.sleepFor, RETRY_DELAY_BINARY);
513514
sinon.assert.calledWith(core.info, 'Error in starting local tunnel: "some message". Trying again in 5 seconds...');
514515
expect(e.message).to.eq('Local tunnel could not be started. Error message from binary: "some message"');
515516
}
@@ -529,7 +530,7 @@ describe('Binary Control Operations', () => {
529530
try {
530531
await binaryControl.startBinary();
531532
} catch (e) {
532-
sinon.assert.calledWith(Utils.sleepFor, 5000);
533+
sinon.assert.calledWith(Utils.sleepFor, RETRY_DELAY_BINARY);
533534
sinon.assert.calledWith(core.info, `Error in starting local tunnel: ${JSON.stringify(response.error)}. Trying again in 5 seconds...`);
534535
expect(e.message).to.eq(`Local tunnel could not be started. Error message from binary: ${JSON.stringify(response.error)}`);
535536
}

0 commit comments

Comments
 (0)