Skip to content

fix(clerk-js): Ensure setActive does not emit token before onBeforeSetActive#5986

Merged
brkalow merged 4 commits intomainfrom
brk.fix/set-active-emit-previous-token
May 28, 2025
Merged

fix(clerk-js): Ensure setActive does not emit token before onBeforeSetActive#5986
brkalow merged 4 commits intomainfrom
brk.fix/set-active-emit-previous-token

Conversation

@brkalow
Copy link
Member

@brkalow brkalow commented May 22, 2025

Description

Currently, we are updating the session token with the new session's token during a session switch, causing the invalidate cache call in onBeforeSetActive() to use the new token. Conceptually, this is wrong. We expect this call to be made with the current (previous) session's token before the new session is actually switched to.

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:

@changeset-bot
Copy link

changeset-bot bot commented May 22, 2025

🦋 Changeset detected

Latest commit: 8f3db30

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 May 22, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 23, 2025 7:08pm

@pkg-pr-new
Copy link

pkg-pr-new bot commented May 22, 2025

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/backend

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

@clerk/elements

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

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/shared

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

@clerk/themes

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

@clerk/types

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

@clerk/upgrade

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

@clerk/vue

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

commit: 8f3db30

@brkalow
Copy link
Member Author

brkalow commented May 22, 2025

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @brkalow - the snapshot version command generated the following package versions:

Package Version
@clerk/agent-toolkit 0.0.38-snapshot.v20250522182206
@clerk/astro 2.8.0-snapshot.v20250522182206
@clerk/backend 1.33.0-snapshot.v20250522182206
@clerk/chrome-extension 2.4.8-snapshot.v20250522182206
@clerk/clerk-js 5.67.3-snapshot.v20250522182206
@clerk/elements 0.23.29-snapshot.v20250522182206
@clerk/clerk-expo 2.11.8-snapshot.v20250522182206
@clerk/expo-passkeys 0.3.6-snapshot.v20250522182206
@clerk/express 1.5.0-snapshot.v20250522182206
@clerk/fastify 2.2.21-snapshot.v20250522182206
@clerk/nextjs 6.20.0-snapshot.v20250522182206
@clerk/nuxt 1.6.7-snapshot.v20250522182206
@clerk/clerk-react 5.31.6-snapshot.v20250522182206
@clerk/react-router 1.4.6-snapshot.v20250522182206
@clerk/remix 4.7.6-snapshot.v20250522182206
@clerk/shared 3.9.3-snapshot.v20250522182206
@clerk/tanstack-react-start 0.15.6-snapshot.v20250522182206
@clerk/testing 1.7.3-snapshot.v20250522182206
@clerk/vue 1.8.4-snapshot.v20250522182206

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/agent-toolkit

npm i @clerk/agent-toolkit@0.0.38-snapshot.v20250522182206 --save-exact

@clerk/astro

npm i @clerk/astro@2.8.0-snapshot.v20250522182206 --save-exact

@clerk/backend

npm i @clerk/backend@1.33.0-snapshot.v20250522182206 --save-exact

@clerk/chrome-extension

npm i @clerk/chrome-extension@2.4.8-snapshot.v20250522182206 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.67.3-snapshot.v20250522182206 --save-exact

@clerk/elements

npm i @clerk/elements@0.23.29-snapshot.v20250522182206 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@2.11.8-snapshot.v20250522182206 --save-exact

@clerk/expo-passkeys

npm i @clerk/expo-passkeys@0.3.6-snapshot.v20250522182206 --save-exact

@clerk/express

npm i @clerk/express@1.5.0-snapshot.v20250522182206 --save-exact

@clerk/fastify

npm i @clerk/fastify@2.2.21-snapshot.v20250522182206 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@6.20.0-snapshot.v20250522182206 --save-exact

@clerk/nuxt

npm i @clerk/nuxt@1.6.7-snapshot.v20250522182206 --save-exact

@clerk/clerk-react

npm i @clerk/clerk-react@5.31.6-snapshot.v20250522182206 --save-exact

@clerk/react-router

npm i @clerk/react-router@1.4.6-snapshot.v20250522182206 --save-exact

@clerk/remix

npm i @clerk/remix@4.7.6-snapshot.v20250522182206 --save-exact

@clerk/shared

npm i @clerk/shared@3.9.3-snapshot.v20250522182206 --save-exact

@clerk/tanstack-react-start

npm i @clerk/tanstack-react-start@0.15.6-snapshot.v20250522182206 --save-exact

@clerk/testing

npm i @clerk/testing@1.7.3-snapshot.v20250522182206 --save-exact

@clerk/vue

npm i @clerk/vue@1.8.4-snapshot.v20250522182206 --save-exact

@brkalow brkalow changed the title fix(clerk-js): Ensure setActive emits previous token for onBeforeSetActive fix(clerk-js): Ensure setActive does not emit token before onBeforeSetActive May 23, 2025
@brkalow brkalow merged commit 68bd90f into main May 28, 2025
36 checks passed
@brkalow brkalow deleted the brk.fix/set-active-emit-previous-token branch May 28, 2025 12:12
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.

5 participants