I am performing a firebase query in order to get tickets in a bugtracker app that belong to a specific project. When I load the page that uses this query, the data sometimes loads the data, and sometimes fails to load the data with this error message:
@firebase/firestore: Firestore (9.6.10): Connection WebChannel transport errored
followed by a 400 POST error (also strange since I am not adding data to the database):
fetchxmlhttpfactory.js:270 POST https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?database=projects%2Fbugtracker-ad036%2Fdatabases%2F(default)&VER=8&gsessionid=WLlKfoxUAL-Qxt242-wHXlDzxIsUI23lt1Wynf2GhDs&SID=AD8kKCDnuwmxndB_gE1gag&RID=80048&AID=161539&zx=qnwq3itw57jk&t=1 400
Also, even if this query manages to work and data is displayed on screen, the process takes abnormally long compared to other queries (~8-10 seconds longer).
This is the specific query and snapshot I am using:
useEffect(() => {
const ticketRef = collection(db, "tickets")
const ticketQuery = query(ticketRef, orderBy("timeStamp", "desc"), where("projectId", "==", projectId), limit(5))
const unsub = onSnapshot(ticketQuery, (snapshot) =>
setTickets(snapshot.docs.map((doc) => ({ ...doc.data(), id:doc.id })))
); return unsub; });
Since I have been reading that the problem might be with how the app is caching data, I'll also include the config file in case that helps:
import { initializeApp } from "firebase/app";
import { getAuth } from "firebase/auth";
import { getFirestore } from "firebase/firestore";
import { getStorage } from "firebase/storage";
const firebaseConfig = {
databaseURL: 'https://bugtracker-ad036.firebaseio.com',
apiKey: process.env.REACT_APP_FIREBASE_KEY,
authDomain: "bugtracker-ad036.firebaseapp.com",
projectId: "bugtracker-ad036",
storageBucket: "XXXXXXXXXXXXXXXX.appspot.com",
messagingSenderId: "XXXXXXXXXXXXXXXXXX",
appId: "1:XXXXXXXXXX:web:XXXXXXXXXXXXXXXXXXXXSS",
};
const app = initializeApp(firebaseConfig);
export const db = getFirestore(app);
export const auth = getAuth()
export const storage = getStorage(app);