fix(api): flag provider topology error state by current status, not stale history (#3619) (#3666)

Closes #3619
This commit is contained in:
Diego Rodrigues de Sa e Souza
2026-06-11 12:55:02 -03:00
committed by GitHub
parent 8c7f37340c
commit 47155fa3a0
3 changed files with 44 additions and 1 deletions

View File

@@ -71,7 +71,12 @@ export async function GET() {
lastProviderTs = requestTs;
}
const errorTs = lastErrorAt ? Date.parse(lastErrorAt) : 0;
// Only flag as errorProvider if the provider's MOST RECENT request was itself
// a failure. A provider with a historical lastErrorAt but a recent success
// (lastStatus 2xx/3xx) must not be shown as currently errored (#3619).
const isCurrentlyInError =
lastStatus !== null && (lastStatus < 200 || lastStatus >= 400);
const errorTs = isCurrentlyInError && lastErrorAt ? Date.parse(lastErrorAt) : 0;
if (Number.isFinite(errorTs) && errorTs > errorProviderTs) {
errorProvider = provider;
errorProviderTs = errorTs;