fix(expo): re-register push token on in-place user switch#1039
Merged
Conversation
The auto-register effect gated on isAuthenticated but not the signed-in userId. Switching users on the same KnockProvider re-auths the same Knock instance (isAuthenticated never flips), so the effect never re-ran and the device token stayed bound to the previous user's channel data. Add userId to the effect deps so a switch re-registers for the new user. Mirrors the Slack/Teams authCheck-on-user-switch fix already in this release. Addresses the Cursor BugBot finding on #1038 (KNO-14229).
🦋 Changeset detectedLatest commit: 6414414 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Bundle ReportChanges will increase total bundle size by 11.97kB (2.13%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: @knocklabs/react-core-react-core-cjsAssets Changed:
view changes for bundle: @knocklabs/react-react-cjsAssets Changed:
view changes for bundle: @knocklabs/react-core-react-core-esmAssets Changed:
view changes for bundle: @knocklabs/expo-expo-esmAssets Changed:
Files in
view changes for bundle: @knocklabs/client-client-cjsAssets Changed:
view changes for bundle: @knocklabs/expo-expo-cjsAssets Changed:
Files in
view changes for bundle: @knocklabs/client-client-esmAssets Changed:
view changes for bundle: @knocklabs/react-react-esmAssets Changed:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## rc #1039 +/- ##
=======================================
Coverage 66.02% 66.02%
=======================================
Files 213 213
Lines 10499 10500 +1
Branches 1509 1509
=======================================
+ Hits 6932 6933 +1
Misses 3542 3542
Partials 25 25
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes the Cursor BugBot finding on #1038: the Expo push auto-register effect does not re-run when the signed-in user changes in place.
useAuthenticatedKnockClientre-authenticates the sameKnockinstance when only the userId changes (it returnscurrentKnock), so on a user A -> user B switch theknockClientidentity is stable andisAuthenticatedstaystrue. The auto-register effect depended onisAuthenticatedbut notuserId, so it never re-ran, leaving the device token bound to user A's channel data.This is the same class as the Slack/Teams "authCheck race on user switch" fix already in this release, applied to the one integration that was missed.
Change
KnockExpoPushNotificationProvider: destructureuserIdfromuseKnockAuthStateand add it to the auto-register effect's dependency array (2 source lines).userIdcontrollable and add a case asserting the token re-registers on an in-place user switch. Verified it fails without the dep and passes with it.@knocklabs/expopatch.Release path
Base is
rcso this rides the same release as #1038: merge here, then mergerc->main(#1038) to publish stable with the fix (@knocklabs/expo@0.7.0).Tracks KNO-14229. The secondary point from the finding (no
unregisterPushTokenFromChannelon auth loss) is intentionally out of scope and captured in the ticket as a separate decision.