mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
Fix: await the ID discovery loop so it runs to completion
The ID discovery script exited about a second after starting. Since the switch to `atMaxRate`, neither the discovery loop nor the request loop was awaited, and `atMaxRate` didn't await its callback, so the script went straight to `save()`, committed and exited while overlapping duplicate requests failed in the background. - Awaited both `atMaxRate` loops and the callback inside `atMaxRate` - Moved the ID range exhaustion check out of the retry loop so retries can't remove extra regions - Treated network and JSON errors as failed API calls so a long run retries instead of crashing without saving Fixes #306
This commit is contained in:
1 parent
116c30be88
commit
3aefe7d985
2 files changed
+16
-13
No files matched your search
@@ -20,7 +20,9 @@ interface MethodContext {
|
||||
let lastT = 0;
|
||||
const maxDelta = 1000 / API_RATE;
|
||||
const DELTA_BUFFER = 0;
|
||||
export async function atMaxRate(method: (context: MethodContext) => void) {
|
||||
export async function atMaxRate(
|
||||
method: (context: MethodContext) => void | Promise<void>,
|
||||
) {
|
||||
let isBroken = false;
|
||||
|
||||
const context: MethodContext = {
|
||||
@@ -39,7 +41,7 @@ export async function atMaxRate(method: (context: MethodContext) => void) {
|
||||
await sleep(maxDelta - delta + DELTA_BUFFER);
|
||||
}
|
||||
|
||||
method(context);
|
||||
await method(context);
|
||||
lastT = t;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user