Skip to content

Commit a63510b

Browse files
committed
sync
1 parent 33959c3 commit a63510b

File tree

1 file changed

+19
-4
lines changed
  • packages/openauth/src/provider

1 file changed

+19
-4
lines changed

packages/openauth/src/provider/oidc.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,27 @@ export function OidcProvider(
105105
const query = config.query || {}
106106
const scopes = config.scopes || []
107107

108-
const wk = fetch(config.issuer + "/.well-known/openid-configuration").then(
109-
async (r) => {
108+
const wk = (async () => {
109+
let retries = 0
110+
while (true) {
111+
const r = await fetch(
112+
config.issuer + "/.well-known/openid-configuration",
113+
).catch((e) => {
114+
console.error(e)
115+
console.log("failed to fetch well-known")
116+
if (e instanceof Error) {
117+
console.log(e.cause)
118+
}
119+
})
120+
if (!r) {
121+
retries++
122+
if (retries > 3) throw new Error("failed to fetch well-known")
123+
continue
124+
}
110125
if (!r.ok) throw new Error(await r.text())
111126
return r.json() as Promise<WellKnown>
112-
},
113-
)
127+
}
128+
})()
114129

115130
const jwks = wk
116131
.then((r) => r.jwks_uri)

0 commit comments

Comments
 (0)