Harden repeated login and auth state handling#620
Draft
andrew-polk wants to merge 2 commits into
Draft
Conversation
|
| Filename | Overview |
|---|---|
| src/connection/ParseServerConnection.ts | Adds in-flight promise deduplication keyed by email, strips the session token from login POST headers, exports hasActiveParseSession, and gates the Sentry alert on showAlert. Logic is correct, including the finally-based cleanup and the alreadyHadSession snapshot. |
| src/authentication/firebase/firebase.ts | Adds an early-return guard in the Parse-login catch handler so a repeated login failure doesn't sign the user out of Firebase when an active Parse session for the same email is already established. |
| src/components/User/UserMenu.tsx | Replaces the stale-closure anti-pattern (loggedInUser in dep array causing re-subscription) with a ref-based previous-value approach; auth state listener is now registered once per mount. The known limitation that firebaseAuthStateChanged doesn't surface an unsubscribe handle is pre-existing. |
| src/connection/LoggedInUser.ts | Wraps MobX autorun in useEffect with [] and returns the disposer, fixing a real leak where a new autorun was created on every render. Also removes the stale-closure condition that compared LoggedInUser.current to a captured-at-mount user value. |
Reviews (2): Last reviewed commit: "Suppress spurious Sentry report on benig..." | Re-trigger Greptile
When the user already has an active Parse session, a failed repeat login is benign, so we already skip the user-facing alert. Skip the Sentry exception in that same case too, so an expected condition isn't reported as an error that could mask genuine login failures. (Greptile P2.) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
andrew-polk
commented
Jul 17, 2026
Contributor
Author
|
🤖 Claude Opus 4.8 (automated preflight) Consulted Devin on 2026-07-17 23:35 UTC up to commit Reviewer results for this HEAD:
|
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.
Hardens the Firebase → Parse Server login flow so that a repeated or concurrent login no longer logs the user out or nags them with an error dialog.
What changed
ParseServerConnection.ts):connectParseServernow returns a single shared in-flight promise keyed by email, so overlapping login attempts for the same user don't fire redundant requests. The tracked promise clears itself on completion.failedToLoginInToParseServernow takes ashowAlertflag) and Firebase no longer signs the user out (firebase.tscatch handler early-returns via the newhasActiveParseSessioncheck).getHeadersForParseLogin): theX-Parse-Session-Tokenheader is removed from the login requests themselves.UserMenu.tsx: thefirebaseAuthStateChangedeffect no longer re-subscribes on everyloggedInUserchange; it reads the previous user through a ref and depends only on[setCookie].LoggedInUser.ts:useGetLoggedInUser/useGetUserIsModeratornow wrap their MobXautoruninuseEffectand return the disposer, so the autorun is cleaned up on unmount instead of leaking a new one per render.Testing
This change is