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);
|
||||
|
||||
// Pooling interval to fetch entries every 31 seconds
|
||||
let fetching = false;
|
||||
interval = setInterval(async () => {
|
||||
if (fetching) return;
|
||||
fetching = true;
|
||||
try {
|
||||
const promise = fetchEntries();
|
||||
// wait for the promise to resolve before assigning to prevent flash
|
||||
|
@ -16,6 +19,8 @@
|
|||
entriesPromise = promise;
|
||||
} catch (error) {
|
||||
console.error('Error fetching entries:', error);
|
||||
} finally {
|
||||
fetching = false;
|
||||
}
|
||||
}, 1000 * 31);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue