Skip to content

Commit 41cb00b

Browse files
committed
use timeouts
1 parent d42ae29 commit 41cb00b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/utils/localstack-status.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,20 @@ function createHealthStatusTracker(
159159
};
160160

161161
let enqueueAgain = false;
162+
162163
const enqueueUpdateStatus = () => {
163164
if (healthCheckTimeout) {
164165
return;
165166
}
166167

167-
healthCheckTimeout = setInterval(() => {
168+
healthCheckTimeout = setTimeout(() => {
168169
void fetchAndUpdateStatus().then(() => {
169170
if (!enqueueAgain) {
170171
return;
171172
}
173+
174+
healthCheckTimeout = undefined;
175+
enqueueUpdateStatus();
172176
});
173177
}, 1_000);
174178
};
@@ -184,7 +188,7 @@ function createHealthStatusTracker(
184188
stop() {
185189
status = undefined;
186190
enqueueAgain = false;
187-
clearInterval(healthCheckTimeout);
191+
clearTimeout(healthCheckTimeout);
188192
healthCheckTimeout = undefined;
189193
},
190194
onChange(callback) {

0 commit comments

Comments
 (0)