refactor: use .finally() to always delete limiter from Map

Address bot review feedback: use .finally() instead of .then()/.catch()
so limiters.delete() runs regardless of whether stop() succeeds or
throws (e.g. already stopped by concurrent 429).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Oleg Saprykin
2026-03-20 18:31:36 +03:00
parent b29456c8e5
commit c009c40606

View File

@@ -350,9 +350,9 @@ export function updateFromHeaders(provider, connectionId, headers, status, model
// be hours for providers like Codex with long rate limit windows).
// This lets upstream callers (e.g. LiteLLM) trigger fallback to other providers.
// After stop, delete from Map so getLimiter() creates a fresh instance.
limiter.stop({ dropWaitingJobs: true }).then(() => {
limiter.stop({ dropWaitingJobs: true }).finally(() => {
limiters.delete(limiterKey);
}).catch(() => {});
});
return;
}