Fix permanent login failure after Zitadel restarts

getOidcConfig() memoized the discovery promise even when it rejected,
so a single failed OIDC discovery (e.g. Zitadel not ready yet when the
dev server starts) permanently broke /auth/login until the process was
restarted. Clear the cached promise on rejection so it retries.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-22 16:29:58 +02:00
co-authored by Claude Sonnet 5
parent aa4b81b9a7
commit ab51d9256e
+5 -2
View File
@@ -17,7 +17,7 @@ export interface Session extends SessionUser {
expiresAt: number;
}
let configPromise: Promise<client.Configuration>;
let configPromise: Promise<client.Configuration> | undefined;
export function getOidcConfig(): Promise<client.Configuration> {
configPromise ??= (async () => {
const issuer = new URL(authConfig.issuer);
@@ -28,7 +28,10 @@ export function getOidcConfig(): Promise<client.Configuration> {
return secret
? client.discovery(issuer, authConfig.clientId, secret, undefined, options)
: client.discovery(issuer, authConfig.clientId, undefined, client.None(), options);
})();
})().catch((exception) => {
configPromise = undefined;
throw exception;
});
return configPromise;
}