Skip to content

Conversation

@brkalow
Copy link
Member

@brkalow brkalow commented Nov 14, 2024

Description

Currently, initialization of a Session resource has a side-effect of emitting a TokenUpdate event. This is problematic for a few reasons:

  1. Setting of the session cookie relies on the clerk.organization "accessor" being available, which is set after the client object is fetched and initialized
  2. Session resources are initialized during the Client object init, so this side-effect triggers before the accessors are available
  3. A global side-effect like this in a class constructor is ripe for problematic bugs

I believe the intent here is to ensure the session cookie is fresh immediately on load of Clerk, and so I've moved this behavior to explicitly live in the Clerk loading flow.

fixes SDKI-765

Checklist

  • npm test runs as expected.
  • npm run 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 Nov 14, 2024

🦋 Changeset detected

Latest commit: e1e8fc4

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

@brkalow brkalow changed the title fix(clerk-js): no TokenUpdate side-effect on new Session() fix(clerk-js): No TokenUpdate side-effect on new Session() Nov 14, 2024
Copy link
Member

@panteliselef panteliselef left a comment

Choose a reason for hiding this comment

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

lgtm

@nikosdouvlis
Copy link
Member

!snapshot

1 similar comment
@nikosdouvlis
Copy link
Member

!snapshot

@vercel
Copy link

vercel bot commented Dec 3, 2024

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 Dec 4, 2024 2:08am

@brkalow brkalow merged commit 5800a1f into main Dec 4, 2024
27 checks passed
@brkalow brkalow deleted the brk.feat/no-token-update-on-init branch December 4, 2024 02:56
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.

6 participants