Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(clerk-js): No TokenUpdate side-effect on new Session() #4555

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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.

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:

Copy link

changeset-bot bot commented Nov 14, 2024

🦋 Changeset detected

Latest commit: 4d1e749

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

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