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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user