Skip to content

fix(auth): prevent infinite loading hang on Firestore snapshot error#689

Open
just-tanvi wants to merge 1 commit into
devpathindcommunity-india:masterfrom
just-tanvi:fix-firebase-sync-loading
Open

fix(auth): prevent infinite loading hang on Firestore snapshot error#689
just-tanvi wants to merge 1 commit into
devpathindcommunity-india:masterfrom
just-tanvi:fix-firebase-sync-loading

Conversation

@just-tanvi

@just-tanvi just-tanvi commented Jun 21, 2026

Copy link
Copy Markdown

Problem

The Firestore onSnapshot listener in src/context/AuthContext.tsx lacked an error callback. Currently, setIsLoading(false) is only called inside the success callback. If the snapshot fails during initialization (due to permission issues, network interruptions, deleted document, or Firestore errors), the success callback is never executed and the application remains stuck in a loading spinner state indefinitely.

Solution

  • Added the standard third-parameter error callback to the Firestore onSnapshot listener.
  • Ensured setIsLoading(false) is called upon error to resolve the loading spinner state and logged the sync error to the console.
  • Updated src/context/__tests__/AuthContext.test.tsx by mocking both onSnapshot success and failure conditions to guarantee that setIsLoading(false) resolves properly in all cases.

Verification Results

  • Unit Tests (npm test): All 19 tests passed, including new test cases for loading-state resolution.
  • E2E Tests (npm run test:e2e): All 28 Playwright tests passed successfully.
  • Production Build (npm run build): Compiled successfully with complete TypeScript and Next.js static asset checks.
  • Linter Check: Passed cleanly on modified files.

closes #686

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 This is a official GirlScript Summer of Code label. level:critical type:bug type:performance type:security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Silent Hangs and Infinite Load State in Firebase Authentication State Listener (AuthContext.tsx)

1 participant