Skip to content

fix: warn when token lifetime is shorter than expiryBuffer#70

Merged
eugenioenko merged 1 commit into
mainfrom
fix/warn-short-lived-tokens
May 8, 2026
Merged

fix: warn when token lifetime is shorter than expiryBuffer#70
eugenioenko merged 1 commit into
mainfrom
fix/warn-short-lived-tokens

Conversation

@eugenioenko
Copy link
Copy Markdown
Owner

Summary

  • Adds a console.warn when the token endpoint returns expires_in shorter than the configured expiryBuffer (default 30s)
  • Warns on both init (token exchange) and refresh paths
  • Helps developers diagnose infinite refresh loops caused by short-lived tokens (e.g., admin sets 29s token lifetime with default 30s buffer)

Context

Investigated how other OIDC libraries handle this (oidc-client-ts, MSAL.js, AppAuth-JS, angular-oauth2-oidc). None of them solve this properly — most just assume tokens live much longer than the buffer. Rather than adding complex capping logic that either breaks proactive refresh or changes function signatures across all adapters, a runtime warning is the pragmatic fix. All framework adapters (React, Vue, Angular, Svelte, etc.) go through OidcClient, so a single warning covers everything.

Test plan

  • Verify pnpm --filter oidc-js-core test passes
  • Verify pnpm --filter oidc-js build succeeds
  • Manual: configure a provider with short token lifetime (<30s) and confirm warning appears in console

🤖 Generated with Claude Code

When the token endpoint returns an expires_in shorter than the configured
expiryBuffer (default 30s), the token is immediately treated as expired,
causing infinite refresh loops. This adds a console.warn at token receipt
(both init and refresh paths) so developers can diagnose the misconfiguration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@eugenioenko eugenioenko merged commit 813dd71 into main May 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant