prevent multiple requests at the same time
This commit is contained in:
parent
a4d5e5d768
commit
d41f907ab6
1 changed files with 5 additions and 0 deletions
|
@ -8,7 +8,10 @@
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
|
|
||||||
// Pooling interval to fetch entries every 31 seconds
|
// Pooling interval to fetch entries every 31 seconds
|
||||||
|
let fetching = false;
|
||||||
interval = setInterval(async () => {
|
interval = setInterval(async () => {
|
||||||
|
if (fetching) return;
|
||||||
|
fetching = true;
|
||||||
try {
|
try {
|
||||||
const promise = fetchEntries();
|
const promise = fetchEntries();
|
||||||
// wait for the promise to resolve before assigning to prevent flash
|
// wait for the promise to resolve before assigning to prevent flash
|
||||||
|
@ -16,6 +19,8 @@
|
||||||
entriesPromise = promise;
|
entriesPromise = promise;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching entries:', error);
|
console.error('Error fetching entries:', error);
|
||||||
|
} finally {
|
||||||
|
fetching = false;
|
||||||
}
|
}
|
||||||
}, 1000 * 31);
|
}, 1000 * 31);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue