0

I'm building an e-commerce app with Next JS 13 and firebase. and there is a page to manage a post. this page only displays post of the user. currently i have 4 documents in my post collection. and with the credential i'm currently logged in has no post. yet the doc read for this is counting as 6 doc reads. i'm using NextAuth with firebase as an adapter. and i'm checking the session status with Next Auth so maybe if that has an effect on the read.

this is what i've done in my code.

export default function ManageListing(){

  const { data: session, status } = useSession();
 const getData = async () => {
    if (status == "authenticated") {
      const constraints = [];
      constraints.push(where("posetedBy", "==", session?.user.email));

      constraints.push(limit(10));
      const livings = collection(db, "posts");
      let q = query(livings, ...constraints);

      const qSnapshot = await getDocs(q);

      const dataQ = qSnapshot.docs.map((doc) => ({
        ...doc.data(),
        id: doc.id,
      }));

      setDatas(dataQ);
    }
  };

  useEffect(() => {
    setLoader(true);

    setTimeout(() => {
      console.log(datas.length);
      if (filled == false) {
        getData();
      }
    }, 1000);
  }, [status == "authenticated"]);

}

as i mentioned above with the account i'm logged in, i've not posted anything so the return should be empty. but Firebase is considering it as a read. even if it counts it as a read it should've been the amount of docs that exists in the collection which is 4. but the read i'm getting from firebase console is sometimes it's 6 or 4 or 8 or 23 or 12... why is this happening?

NB. my firebase console is not open, only the usage section and it has no effect on the read.

SG_stack
  • 43
  • 5
  • 2
    Normally it is the console, or misuse of react hooks. You should add some logging to your app every time you perform query to see what it's actually doing. – Doug Stevenson Jun 05 '23 at 12:31
  • @DougStevenson but it is NOT. b/c i'm running other pages to load and it works fine as expected. why is this d/t? I only opened usage tab to monitor my usage. and i have logged my datas it's only calling it once. and the returned data is empty. – SG_stack Jun 05 '23 at 12:33
  • @DougStevenson i think the only problem here is Firebase. b/c last week i had the same issue on a d/t page and it was calculating correctly after i put conditionals. but when i run that same page now its calculations is messed up. i'm running my code in production mode. – SG_stack Jun 05 '23 at 12:43
  • 2
    If you think there is a problem with what the console is reporting and the problem is not with your code, then Stack Overflow is not going to be of much help to you. Contact [Firebase support](https://support.google.com/firebase/contact/support) directly and explain what the product is doing wrong. We as volunteers can only help you with what you provide as code. – Doug Stevenson Jun 05 '23 at 13:00
  • @DougStevenson thank you, and i'm sorry if i offended you. – SG_stack Jun 05 '23 at 13:20

1 Answers1

1

Posting this as a community wiki so that others can benefit from it.


As mentioned by @Doug Stevenson:

If you think there is a problem with what the console is reporting and the problem is not with your code, then Stack Overflow is not going to be of much help to you. Contact Firebase support directly and explain what the product is doing wrong. We as volunteers can only help you with what you provide as code.


If you have a clearly defined bug (with a Minimal, Complete, and Verifiable example) that is not specific to your project, file it here.


In addition to that you can also file a bug in this link.

Chanpols
  • 1,184
  • 1
  • 3
  • 13