Skip to content

Commit 064ba03

Browse files
committed
adding pollingInterval setter
1 parent cdffece commit 064ba03

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

browserstack-report-action/dist/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38745,6 +38745,7 @@ class ReportService {
3874538745
}
3874638746

3874738747
async pollReport(params, timeManager, maxRetries, pollingInterval) {
38748+
timeManager.setPollingInterval(pollingInterval);
3874838749
const poll = async (retries) => {
3874938750
if (timeManager.checkTimeout()) {
3875038751
return this.handleErrorStatus(constants.REPORT_STATUS.IN_PROGRESS);
@@ -38764,7 +38765,7 @@ class ReportService {
3876438765
}
3876538766

3876638767
if (status === constants.REPORT_STATUS.IN_PROGRESS && retries < maxRetries) {
38767-
await timeManager.sleep(pollingInterval);
38768+
await timeManager.sleep();
3876838769
return poll(retries + 1);
3876938770
}
3877038771

@@ -38810,13 +38811,16 @@ class TimeManager {
3881038811
return false;
3881138812
}
3881238813

38814+
setPollingInterval(seconds) {
38815+
this.pollingInterval = seconds;
38816+
}
38817+
3881338818
/**
3881438819
* Sleep for specified seconds
3881538820
* @param {number} seconds - Number of seconds to sleep
3881638821
* @returns {Promise} - Promise that resolves after the specified time
3881738822
*/
38818-
async sleep(seconds) {
38819-
this.pollingInterval = seconds;
38823+
async sleep() {
3882038824
return new Promise((resolve) => setTimeout(resolve, this.pollingInterval * 1000));
3882138825
}
3882238826
}

browserstack-report-action/src/services/ReportService.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class ReportService {
3939
}
4040

4141
async pollReport(params, timeManager, maxRetries, pollingInterval) {
42+
timeManager.setPollingInterval(pollingInterval);
4243
const poll = async (retries) => {
4344
if (timeManager.checkTimeout()) {
4445
return this.handleErrorStatus(constants.REPORT_STATUS.IN_PROGRESS);
@@ -58,7 +59,7 @@ class ReportService {
5859
}
5960

6061
if (status === constants.REPORT_STATUS.IN_PROGRESS && retries < maxRetries) {
61-
await timeManager.sleep(pollingInterval);
62+
await timeManager.sleep();
6263
return poll(retries + 1);
6364
}
6465

browserstack-report-action/src/utils/TimeManager.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ class TimeManager {
1111
return false;
1212
}
1313

14+
setPollingInterval(seconds) {
15+
this.pollingInterval = seconds;
16+
}
17+
1418
/**
1519
* Sleep for specified seconds
1620
* @param {number} seconds - Number of seconds to sleep
1721
* @returns {Promise} - Promise that resolves after the specified time
1822
*/
19-
async sleep(seconds) {
20-
this.pollingInterval = seconds;
23+
async sleep() {
2124
return new Promise((resolve) => setTimeout(resolve, this.pollingInterval * 1000));
2225
}
2326
}

0 commit comments

Comments
 (0)