-
Notifications
You must be signed in to change notification settings - Fork 435
fix(astro): Use batched stores to avoid race conditions in auth store #4000
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@clerk/astro": patch | ||
| --- | ||
|
|
||
| Fix incorrect authentication state when subscribing to client stores. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import { deriveState } from '@clerk/shared/deriveState'; | ||
| import { eventMethodCalled } from '@clerk/shared/telemetry'; | ||
| import { computed, onMount, type Store } from 'nanostores'; | ||
| import { batched, computed, onMount, type Store } from 'nanostores'; | ||
|
|
||
| import { $clerk, $csrState, $initialState } from './internal'; | ||
|
|
||
|
|
@@ -13,7 +13,7 @@ import { $clerk, $csrState, $initialState } from './internal'; | |
| * | ||
| * $authStore.subscribe((auth) => console.log(auth.userId)) | ||
| */ | ||
| export const $authStore = computed([$csrState, $initialState], (state, initialState) => { | ||
| export const $authStore = batched([$csrState, $initialState], (state, initialState) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this return a read only store similar to computed ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes readonly too |
||
| return deriveState( | ||
| state.isLoaded, | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,10 +16,10 @@ export const $csrState = map<{ | |
| organization: OrganizationResource | undefined | null; | ||
| }>({ | ||
| isLoaded: false, | ||
| client: null, | ||
| user: null, | ||
| session: null, | ||
| organization: null, | ||
| client: undefined, | ||
| user: undefined, | ||
| session: undefined, | ||
| organization: undefined, | ||
|
Comment on lines
+19
to
+22
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my comment here. Putting the update here as they're related |
||
| }); | ||
|
|
||
| export const $initialState = map<InitialState>(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version bump with bug fixes and perf improvements. No breaking change. See changelog