openvibers/openvibe.media Commits

JWKS: retry every 30s until the Network key loads (boot-order race)

OP OpenVibers committed 17 Aug 2026 · 6a962e2026 · 1 file, +6 −1

A single failed fetch at startup left user-JWT auth down for 6 hours.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xw6Sf5zzSALw8m93XNu5JE

Changes

ddiff --git a/server/auth.js b/server/auth.js
iindex c4a67bd..3fd076d 100644
---- a/server/auth.js
++++ b/server/auth.js
@@@ -49,7 +49,12 @@ async function fetchNetworkPublicKey() {
}
function startJwksRefresh() {
-- fetchNetworkPublicKey().catch(() => {});
++ // Until the key loads, retry every 30s — Network may still be booting
++ // (user-JWT auth is down for browsers the whole time the key is missing).
++ const tryLoad = () => fetchNetworkPublicKey().then((pem) => {
++ if (!pem) setTimeout(tryLoad, 30 * 1000).unref?.();
++ }).catch(() => { setTimeout(tryLoad, 30 * 1000).unref?.(); });
++ tryLoad();
_jwksTimer = setInterval(() => fetchNetworkPublicKey().catch(() => {}), 6 * 60 * 60 * 1000);
if (_jwksTimer.unref) _jwksTimer.unref();
}