This is a test project used to reproduce a Firestore problem with experimentalAutoDetectLongPolling
.
There's 3 ways of using Firestore written in this project:
- Use
namespaced/compat
api:
- File
01_compat.js
- Enable this import line in
ForestoreTest.jsx
:
import fetchDocs from './01_compat'
- Use normal
modular
api:
- File
02_modular.js
- Enable this import line in
ForestoreTest.jsx
:
import fetchDocs from './02_modular'
- Use
lite
modular api:
- File
03_lite.js
- Enable this import line in
ForestoreTest.jsx
:
import fetchDocs from './02_lite'
It's supposed that all Firestore requests work without any problem, though experimentalAutoDetectLongPolling
is activated explicitly or implicitly default by SDK. But it's not. The actuality runs as below:
- With
compat
api, we need this line for Firestore to work:
firebase.firestore().settings({ experimentalAutoDetectLongPolling: true })
- With
modular
api, none of these 2 firestore initializations work:
// 1
const firestore = getFirestore(app)
// 2
const firestore = initializeFirestore(app, {
experimentalAutoDetectLongPolling: true,
})
- With
lite
api, both of these 2 firestore initializations work:
// 1
const firestore = getFirestore(app)
// 2
const firestore = initializeFirestore(app, {
experimentalAutoDetectLongPolling: true,
})
It's weird that lite
api works, normal modular
api does not work.
And compat
api work only if we activate experimentalAutoDetectLongPolling
(experimentalForceLongPolling
) explicitly.
- Clone this project
- Run
npm install
- Determine which Firestore version to use (compat, modular, lite) by toggling the corresponding import in
FirestoreTest.jsx
file
// NOTE: Use one of the following imports to test the different versions
// 1
import fetchDocs from './01_compat'
// 2
import fetchDocs from './02_modular'
// 3
import fetchDocs from './03_lite'
- Run
npm run dev
- Open browser
http://localhost:5173/