Skip to content

Commit 310a44f

Browse files
ggazzoclaude
andcommitted
fix(sdk): reset syncOnce dedup on uid transition to undefined
The loginWithToken wrap clears creds via Accounts._unstoreLoginToken() + Meteor.connection.setUserId(null), which does NOT fire Accounts.onLogout. Without resetting lastSyncedUid on the resulting uid=undefined transition, a subsequent re-login (e.g. e2ee-passphrase-management's loginByUserState of the same user) is deduped and runUserDataSync never runs — the page stays wedged on PageLoading and the Login button never hides. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 841c0d2 commit 310a44f

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

apps/meteor/client/startup/startup.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,17 @@ const runUserDataSync = async (uid: string) => {
5757
// false and the page stuck on PageLoading.
5858
let lastSyncedUid: string | undefined;
5959
const syncOnce = (uid: string | undefined): void => {
60-
if (!uid || uid === lastSyncedUid) return;
60+
// Reset on logout transitions so a subsequent re-login (same uid or different)
61+
// runs a fresh sync. Force-logout via the SDK loginWithToken wrap clears
62+
// creds via Accounts._unstoreLoginToken() + setUserId(null), which does NOT
63+
// fire Accounts.onLogout — so without this branch, lastSyncedUid stays set,
64+
// the next login is deduped, runUserDataSync is skipped, and
65+
// useUserDataSyncReady stays false (page wedged on PageLoading).
66+
if (!uid) {
67+
lastSyncedUid = undefined;
68+
return;
69+
}
70+
if (uid === lastSyncedUid) return;
6171
lastSyncedUid = uid;
6272
void runUserDataSync(uid).catch((err) => {
6373
console.warn('[startup] runUserDataSync failed; clearing dedup to allow a retry', err);

0 commit comments

Comments
 (0)