test(clerk-js): Add tests for varying token TTL across refreshes#8100
test(clerk-js): Add tests for varying token TTL across refreshes#8100nikosdouvlis merged 2 commits intomainfrom
Conversation
…freshes Verify that the token cache correctly adapts refresh timers when consecutive tokens have different TTLs (e.g. 60s -> 200s -> 60s). Each token's refresh timer is computed from its own exp-iat, not a fixed interval.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 10358e4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA new test suite was added to the tokenCache test file to validate timer behavior across consecutive tokens with varying TTLs. Tests cover TTL transitions (60s ↔ 200s and combinations), verify refresh-timer adaptation and onRefresh invocations, ensure replacements preserve or extend validity, and check that old deletion timers don’t remove longer-lived tokens. Additional scenarios validate token readability during transitions, async resolution lifecycles, broadcast behavior, and multi-session isolation. No production code was changed. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📝 Coding Plan
Comment Tip You can customize the tone of the review comments and chat replies.Configure the |
With the upcoming work to allow emergency TTL overrides from clerk_go (see clerk/clerk_go#17599), we want to be confident that clerk-js handles consecutive tokens with different TTLs correctly.
The token cache already computes refresh timers dynamically from each token's own
exp - iat, so varying TTL works out of the box. But there were no tests covering the chained scenario where Token A refreshes into Token B with a different TTL.This adds 5 tests to
tokenCache.test.ts:deleteKey)Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit