'React-js with Firebase offline-persistance not working as Expected

App Works fine in Windows chrome but all this noted issues where found in Android chrome.

App works fine when user goes offline and firebase cache is also working and returning data even is offline but the problem is when user kills the app and re-open it then firebase is not returning any cached data.

STEPS :

  1. install as PWA.
  2. Close chrome and open as App.
  3. App is working fine.
  4. Now turn off the internet.
  5. Still app is accessing previous cached data and returning results (Works fine). ---- offline ---
  6. Now kill the app.
  7. Now Re-open. Firestore wont return the cached results as expected it just stucks in getDocs call. await getDoc() just stuck here and not executing the next line.

NOTE: App passes PWA criteria in Light house. Service worker has been added successfully and it was shown in DevTools service worker tab and we are also using workebox.

try {
  enableIndexedDbPersistence(db);
} catch (error) {
  window.alert(`${error.code} - Error in Persisting`)
  console.error(error)
}

No error has been thrown

Any suggestions, What may be the problem ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source