Skip to content

fix(mosaic,shared): clear cached device sessions after sign-out - #10555

Open
austincalvelage wants to merge 1 commit into
mainfrom
austin/core-4131-clear-cached-device-sessions-after-section-unmount-and-sign
Open

austincalvelage wants to merge 1 commit into
mainfrom
austin/core-4131-clear-cached-device-sessions-after-section-unmount-and-sign

Conversation

@austincalvelage

@austincalvelage austincalvelage commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Description

Fixes CORE-4131.

Closing Active Devices before signing out left session and IP data in the shared query cache. Register cleanup with the persistent query client so confirmed sign-out removes those entries even after the section unmounts. Undefined auth state preserves the cache, and existing billing cleanup keeps its current behavior.

This changes in-memory cache cleanup, with no visible change to the Mosaic UI. The cache still survives closing and reopening Active Devices while signed in. Confirmed sign-out removes it even if the section has already unmounted.

Verified before and after in Chromium with a real Clerk instance and synthetic Frontend API responses: mount Active Devices, populate the cache, unmount, then sign out. Before the fix, the query still held session and IP data. After the fix, the original query entry was absent from the same persistent client. The mounted sign-out control also passes. Shared tests cover undefined auth, repeated registration, listener disposal, and late request completion.

Checklist

  • pnpm test runs as expected for the affected suites: all 1,357 shared tests, 2,959 legacy UI tests, 1,296 Clerk runtime tests, and 30 active-device browser tests pass.
  • pnpm build runs as expected. The shared and legacy UI production builds and affected typechecks pass; the full monorepo build was not run.
  • (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:

@vercel

vercel Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
clerk-js-sandbox Ready Ready Preview Oct 30, 2026 11:23pm UTC
swingset Ready Ready Preview Oct 30, 2026 11:23pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2451528

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

This PR includes changesets to release 23 packages
Name Type
@clerk/shared Patch
@clerk/mosaic Patch
@clerk/astro Patch
@clerk/backend Patch
@clerk/chrome-extension Patch
@clerk/clerk-js Patch
@clerk/electron Patch
@clerk/expo-passkeys Patch
@clerk/expo Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/hono Patch
@clerk/localizations Patch
@clerk/msw Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/react Patch
@clerk/swingset Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/ui Patch
@clerk/vue 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

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
Commits

Reviewing files that changed from the base of the PR and between fc47da2 and 2451528.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between a7e5619 and 27feecb.

Files selected for processing: 8
  • .changeset/quiet-devices-sign-out.md
  • packages/mosaic/src/features/user-profile/user-profile-active-devices-section/__tests__/user-profile-active-devices-section.feature.test.tsx
  • packages/mosaic/src/queries/use-user-sessions-query.ts
  • packages/shared/src/react/hooks/__tests__/usePersistentQueryCleanupOnSignOut.spec.ts
  • packages/shared/src/react/hooks/index.ts
  • packages/shared/src/react/hooks/useClearQueriesOnSignOut.ts
  • packages/shared/src/react/query/__tests__/clerk-query-client.spec.ts
  • packages/shared/src/react/query/clerk-query-client.ts
Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. 5 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 6 reviews per hour.

Walkthrough

The change adds persistent sign-out cleanup for registered authenticated query keys. When the Clerk user becomes null, matching queries are removed, including after the related section unmounts. The sessions query uses the new cleanup hook. Tests cover subscription lifecycle and cache behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Severity of issue fixed: Low

Merge Risk: Minimal · previous review 27fee

No merge-blocking risk is established from the available evidence.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: clearing cached device sessions after sign-out in Mosaic and shared code.
Description check Passed The description directly explains the cache cleanup fix, affected behavior, testing, and scope. It is related to the changeset.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 7 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Linked repositories: Some configured repositories could not be included in this review. Cross-repository analysis may be incomplete. Please check linked-repository access and settings.

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

@pkg-pr-new

pkg-pr-new Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@10555

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@10555

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@10555

@clerk/expo

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

@clerk/expo-biometrics

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

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@10555

@clerk/expo-native-components

npm i https://pkg.pr.new/@clerk/expo-native-components@10555

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@10555

@clerk/localizations

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

@clerk/mosaic

npm i https://pkg.pr.new/@clerk/mosaic@10555

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@10555

@clerk/upgrade

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

@clerk/vue

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

commit: 2451528

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-10-30T23:24:10.676Z

Summary

Metric Count
Packages analyzed 20
Packages with changes 1
🔴 Breaking changes 0
🟡 Non-breaking changes 0
🟢 Additions 1

@clerk/shared

Current version: 4.43.1
Recommended bump: MINOR → 4.44.0

Subpath ./react

🟢 Additions (1)

Added: __internal_usePersistentQueryCleanupOnSignOut
+ declare function usePersistentQueryCleanupOnSignOut(stableKey: string): void;

Added function __internal_usePersistentQueryCleanupOnSignOut


Report generated by Break Check

Last ran on 2451528.

This branch was successfully deployed

2 active deployments
Preview – swingset — 24515288 Deployed Oct 30, 2026 by vercel[bot]
Preview – clerk-js-sandbox — 24515288 Deployed Oct 30, 2026 by vercel[bot]
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.

1 participant