Skip to content

Conversation

@octoper
Copy link
Member

@octoper octoper commented Nov 28, 2025

Description

Reverts #7105

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • Revert

    • Reverted a prior change that affected session token handling; caching behavior restored to previous behavior.
  • Bug Fixes

    • Ensured session tokens with updated claims are written to the cache so authentication state is persisted correctly.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Nov 28, 2025

🦋 Changeset detected

Latest commit: ea63e50

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch

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

@vercel
Copy link

vercel bot commented Nov 28, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Ready Ready Preview Comment Nov 28, 2025 1:07pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 28, 2025

Walkthrough

Reverts a prior Clerk JS change (PR 7105) via a new changeset and updates Session hydration to always write a provided token into SessionTokenCache, removing the previous early-return and existing-cache check.

Changes

Cohort / File(s) Summary
Changeset documentation
.changeset/two-candles-yawn.md
Adds a new changeset documenting the revert of PR 7105 for @clerk/clerk-js (patch bump) due to JWTs with updated claims not being inserted into the cache.
Session token caching logic
packages/clerk-js/src/core/resources/Session.ts
Alters hydration logic to write the computed tokenId and token into SessionTokenCache when a non-null token is present; removes the prior early-return and check for an existing cache entry that prevented writes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Single focused behavioral change but affects caching semantics; verify scenarios where tokens are refreshed or claims change.
  • Pay attention to tests around hydration, cache invalidation, and concurrent token updates.
  • Check for potential regressions where preserving previous cache entries was relied upon.

Poem

🐇 I nibble code beneath the moon,

I write the token, write it soon,
No skipping now, the cache will sing,
Claims refreshed — new joy they bring,
A hop, a patch, a quiet tune.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: reverting a hydrate cache change for the session resource in clerk-js, which aligns with the changeset and the modifications to Session.ts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch vaggelis/revert-hydrate-cache-change-7105

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6c71429 and ea63e50.

📒 Files selected for processing (1)
  • .changeset/two-candles-yawn.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/two-candles-yawn.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (31)
  • GitHub Check: Integration Tests (quickstart, chrome, 15)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (machine, chrome, RQ)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 15, RQ)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (billing, chrome, RQ)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Static analysis
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Unit Tests (22, shared, clerk-js, RQ)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan

Comment @coderabbitai help to get the list of available commands and usage tips.

@octoper octoper requested a review from brkalow November 28, 2025 13:03
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4fae43c and 6c71429.

📒 Files selected for processing (2)
  • .changeset/two-candles-yawn.md (1 hunks)
  • packages/clerk-js/src/core/resources/Session.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

All code must pass ESLint checks with the project's configuration

Files:

  • packages/clerk-js/src/core/resources/Session.ts
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/clerk-js/src/core/resources/Session.ts
packages/**/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/core/resources/Session.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Follow established naming conventions (PascalCase for components, camelCase for variables)

Prefer importing types from @clerk/shared/types instead of the deprecated @clerk/types alias

Files:

  • packages/clerk-js/src/core/resources/Session.ts
packages/**/src/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

packages/**/src/**/*.{ts,tsx,js,jsx}: Maintain comprehensive JSDoc comments for public APIs
Use tree-shaking friendly exports
Validate all inputs and sanitize outputs
All public APIs must be documented with JSDoc
Use dynamic imports for optional features
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Implement proper logging with different levels

Files:

  • packages/clerk-js/src/core/resources/Session.ts
**/*.ts?(x)

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

Files:

  • packages/clerk-js/src/core/resources/Session.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Implement type guards for unknown types using the pattern function isType(value: unknown): value is Type
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details in classes
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Use mixins for shared behavior across unrelated classes in TypeScript
Use generic constraints with bounded type parameters like <T extends { id: string }>
Use utility types like Omit, Partial, and Pick for data transformation instead of manual type construction
Use discriminated unions instead of boolean flags for state management and API responses
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation at the type level
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Document functions with JSDoc comments including @param, @returns, @throws, and @example tags
Create custom error classes that extend Error for specific error types
Use the Result pattern for error handling instead of throwing exceptions
Use optional chaining (?.) and nullish coalescing (??) operators for safe property access
Let TypeScript infer obvious types to reduce verbosity
Use const assertions with as const for literal types
Use satisfies operator for type checking without widening types
Declare readonly arrays and objects for immutable data structures
Use spread operator and array spread for immutable updates instead of mutations
Use lazy loading for large types...

Files:

  • packages/clerk-js/src/core/resources/Session.ts
🧬 Code graph analysis (1)
packages/clerk-js/src/core/resources/Session.ts (1)
packages/clerk-js/src/core/tokenCache.ts (1)
  • SessionTokenCache (413-413)
🪛 markdownlint-cli2 (0.18.1)
.changeset/two-candles-yawn.md

5-5: Bare URL used

(MD034, no-bare-urls)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (33)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (quickstart, chrome, 16)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 15, RQ)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (billing, chrome, RQ)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome, 15)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 16)
  • GitHub Check: Integration Tests (machine, chrome, RQ)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Unit Tests (22, shared, clerk-js, RQ)
  • GitHub Check: Static analysis
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
packages/clerk-js/src/core/resources/Session.ts (1)

133-140: Cache hydration behavior looks correct and matches revert intent

Seeding SessionTokenCache whenever a non‑null token is present (using tokenId: this.#getCacheId() and tokenResolver: Promise.resolve(token)) ensures the constructor-hydrated lastActiveToken is always reflected in the cache, instead of silently reusing potentially stale entries. This aligns with the goal of making piggybacked JWTs with changed claims actually land in the cache, and the API usage is consistent with _getToken’s SessionTokenCache.set calls.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 28, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7329

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@7329

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@7329

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@7329

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@7329

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7329

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@7329

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@7329

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@7329

@clerk/express

npm i https://pkg.pr.new/@clerk/express@7329

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@7329

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@7329

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@7329

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@7329

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@7329

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@7329

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@7329

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@7329

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@7329

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@7329

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@7329

@clerk/types

npm i https://pkg.pr.new/@clerk/types@7329

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@7329

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@7329

commit: ea63e50

@octoper octoper requested a review from bratsos November 28, 2025 13:34
@octoper octoper merged commit a11c2da into main Nov 28, 2025
78 of 79 checks passed
@octoper octoper deleted the vaggelis/revert-hydrate-cache-change-7105 branch November 28, 2025 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants