Skip to content

Mobile Persistence Troubleshooting - Step by Step โ€‹

Issue: Login not persisting after refresh on Pixel Chrome
Date: January 7, 2026

Root Causes We're Investigating โ€‹

  1. Race condition: setPersistence might not complete before auth listener starts
  2. Cloudflare caching: May be serving stale JS/service worker
  3. Chrome settings: Might have storage restrictions enabled
  4. IndexedDB conflicts: Multiple persistence mechanisms interfering
  5. Network timing: Auth might not restore quickly enough on poor connection

What We've Fixed โ€‹

  1. Made persistence synchronous - Now waits for setPersistence to complete BEFORE setting up listeners
  2. Removed IndexedDB warmup - Was creating race condition with Firestore persistence
  3. Improved Cloudflare headers - Disabled caching for HTML/index to prevent stale JS
  4. Simplified initialization - Removed competing async operations

On Your Pixel Device - Chrome Settings to Check โ€‹

Possible Restrictions โ€‹

Settings > Site settings > Cookies and site data

  • [ ] Check if "Clear on exit" is enabled (would delete auth on close)
  • [ ] Check if "Block third-party cookies" is on
  • [ ] Verify "All cookies allowed" for dev.ourlantern.app

Settings > Apps > Chrome > Permissions

  • [ ] Storage: Should be "Allowed"
  • [ ] Check if you're in restricted/work profile (would disable localStorage)

Settings > Apps > Chrome > Storage

  • [ ] Check available space (low storage can prevent caching)
  • [ ] Clear cache if >500MB

Safe Testing โ€‹

  1. Create new Chrome profile (not restricted)

    • Settings > Accounts > Add account
    • Select personal Google account
    • Switch to new profile
  2. Test app on new profile

    • Login
    • Force close
    • Reopen
    • Should stay logged in

If Still Not Working - Manual Workaround โ€‹

While we debug the persistence issue, users can manually stay logged in:

1. Login to dev.ourlantern.app
2. Bookmark the page (Chrome menu > Bookmark this page)
3. Close Chrome (no force-close)
4. Reopen from bookmark
5. This preserves session better

What's Actually Happening Now โ€‹

Before (Broken) โ€‹

Firebase Auth persistence set to LOCAL
โ†“
IndexedDB warmup starts (async)
โ†“
Auth listener sets up (before persistence ready)
โ†“
No cached user found = login form shown
โ†“
Performance is slow

After (Fixed) โ€‹

Firebase Auth persistence set to LOCAL (await)
โ†“
IndexedDB persistence enabled (await)
โ†“
Auth listener sets up (persistence guaranteed ready)
โ†“
Cached user found = dashboard shown
โ†“
Fast performance

Testing for Us to Verify โ€‹

Please try these and report results:

Test 1: Check Persistence is Actually Set โ€‹

1. Open DevTools Console
2. Paste: firebase.auth()._persistence?.type
3. Should return: "LOCAL"
4. If returns "SESSION" or undefined = persistence not set

Test 2: Check localStorage โ€‹

1. DevTools > Application > Local Storage
2. Look for entries with "firebase:" prefix
3. Should see multiple firebase keys
4. If empty = persistence not working

Test 3: Check Auth State โ€‹

1. DevTools Console
2. Paste: firebase.auth().currentUser
3. If logged in: shows {uid: "...", email: "..."}
4. If logged out: returns null

Test 4: Check Cloudflare Cache โ€‹

1. DevTools > Network tab
2. Reload page
3. Look at response headers for "index.html"
4. Should NOT have "cf-cache-status: HIT"
5. If it does = Cloudflare is serving stale HTML

If Cloudflare is Caching HTML โ€‹

This could prevent new JS from loading. To fix:

  1. Via Cloudflare Dashboard:

    • Go to dev.ourlantern.app zone
    • Caching > Purge Cache > Purge everything
    • Wait 5 minutes
    • Try again
  2. Or locally:

    • Settings > Apps > Chrome > Storage > Clear all site data
    • Hard reload: Ctrl+Shift+R
    • Try login again

Chrome Mobile Settings (Universal) โ€‹

On Pixel:

  1. Settings > Apps > Chrome

    • Permissions > Storage = Allowed
    • Permissions > Cookies = Allowed
    • Storage > Clear cache (if >500MB)
  2. Settings > System > Developer options

    • USB Debugging = OFF (shouldn't affect localStorage)
    • Any storage restrictions = check OFF
  3. Settings > Privacy

    • Incognito: Make sure you're NOT using incognito mode
    • Enhanced safe browsing: Can be ON or OFF (shouldn't matter)

The Real Culprit - Most Likely โ€‹

Based on similar issues, the problem is probably:

  1. Multiple Chrome profiles with restrictions - Switch to personal profile
  2. IndexedDB failing silently - We've disabled this now
  3. Cloudflare serving stale HTML - Just purged cache
  4. Race condition on page load - We've fixed this

What to Try First โ€‹

Ranking of likelihood to fix it:

  1. โญโญโญ Purge Cloudflare cache - Most likely

    • Dev.ourlantern.app zone
    • Caching > Purge Cache > Purge Everything
  2. โญโญโญ Check Chrome profile is personal - Very likely

    • Settings > Accounts
    • Not work/school account
  3. โญโญ Check Site Settings > Cookies

    • Allow cookies for dev.ourlantern.app
    • Don't clear on exit
  4. โญ Clear site data locally

    • Settings > Apps > Chrome > Storage > Clear all site data
    • Hard reload app: Ctrl+Shift+R

Advanced Debugging (if still broken) โ€‹

javascript
// In DevTools Console, run:

// 1. Check persistence type
console.log('Persistence:', firebase.auth()._persistence?.type)

// 2. Check localStorage
console.log('LocalStorage keys:', Object.keys(localStorage).filter(k => k.includes('firebase')))

// 3. Check if auth state listener fires
firebase.auth().onAuthStateChanged(user => {
  console.log('Auth state changed:', user?.uid || 'logged out')
})

// 4. Wait 2 seconds and check again
setTimeout(() => {
  console.log('Current user:', firebase.auth().currentUser?.uid || 'none')
}, 2000)

// 5. Force refresh auth state
firebase.auth()._notifyListeners()

If Still Persisting โ€‹

Please share:

  1. Results of Test 1-4 above
  2. Pixel device model (6, 7, 8 Pro, etc)
  3. Chrome version (Settings > About Chrome)
  4. Exact steps you're taking when it fails
  5. Console output from the debug commands

With this info we can narrow down the exact cause.

Temporary Workaround for Users โ€‹

Until we solve this:

1. Login
2. Add to Home Screen (Chrome menu > Install app)
3. Use as PWA
4. PWA has better persistence than browser
5. Bookmark backup: Chrome > Bookmark this page

Files Modified in This Fix โ€‹

  • src/firebase.js - Made persistence synchronous with await
  • src/main.jsx - Removed IndexedDB warmup race condition
  • public/_headers - Added Cloudflare optimization headers

Build and deploy changes, then:

  1. Purge Cloudflare cache
  2. Hard refresh Pixel (Ctrl+Shift+R)
  3. Test login persistence

Built with VitePress