get unstuck

This commit is contained in:
dervperson 2025-02-01 00:50:27 -05:00
parent 0c070c5aec
commit ffc071adbb

12
site.js
View file

@ -71,17 +71,23 @@ async function rounder(users, data, mode) {
let p = []; let p = [];
let congested = []; let congested = [];
let timeout = false; let timeout = false;
setTimeout(function() {
let pr = new Promise(resolve => setTimeout(function (...ag) {
timeout = true; timeout = true;
},(process.env.delay*1000) || (60*1000)); resolve(ag);
}, (process.env.delay * 1000) || (60 * 1000)))
for (let u of users) { for (let u of users) {
if (timeout) break; if (timeout) break;
let it = 0; let it = 0;
while (p.length >= (process.env.maxRate || 15)) { while (p.length >= (process.env.maxRate || 15)) {
p = p.filter(x => x != 'hi'); p = p.filter(x => x != 'hi');
if (timeout) {
console.warn(`Somehow, this is stuck.`);
break;
}
if (p.length == 0) break; if (p.length == 0) break;
let pv = await Promise.any(p); let pv = await Promise.any([...p,pr]);
it++; it++;
if (it > 10) { if (it > 10) {
console.warn(`Promises got congested. Moving to another array...`) console.warn(`Promises got congested. Moving to another array...`)