vuejs / vuefire

🔥 Firebase bindings for Vue.js
https://vuefire.vuejs.org
MIT License
3.82k stars 323 forks source link

AppCheck gets tokens in infinite loop #1357

Closed bogdanciuca closed 11 months ago

bogdanciuca commented 1 year ago

Reproduction

N/A

Steps to reproduce the bug

Write some code that will trigger an error, for example:

const { data, pending, error, refresh } = await useAsyncData(
  'articles',
  () => getDocs(query(collection(useFirestore(), 'articles'), where('published', '==', true))),
)

Expected behavior

The page should display the error, i.e. "500 Maximum call stack size exceeded" in this case. Logs should be:

Cannot stringify arbitrary non-POJOs QuerySnapshot
[nuxt] [request error] [unhandled] [500] Maximum call stack size exceeded   

Actual behavior

The page never loads, as Vuefire gets new AppCheck tokens in an infinite loop. Logs are full of:

[VueFire]: Getting Admin AppCheck
[VueFire]: Getting creating token for app <APP_ID>
[VueFire]: Got AppCheck token from the server: <TOKEN>

Additional information

It also seems somehow related to authentication. On "public" pages, a simple const articles = useCollection(collection(useFirestore(), 'articles')) would also trigger this behaviour. On pages using auth middleware, there are no issues.

posva commented 11 months ago

This should be fixed now