Suspense triggers weird bug

I have a component like this:
async function Foo() {
const { userId } = auth()
if (!userId) return
console.count()
const existingAccount = await getAccount(userId)
const account = existingAccount
? existingAccount
: await createAccountAndProfile() //this line should only get called the first time but it gets called twice
if (!account) throw new Error(ERR.db)
}
async function Foo() {
const { userId } = auth()
if (!userId) return
console.count()
const existingAccount = await getAccount(userId)
const account = existingAccount
? existingAccount
: await createAccountAndProfile() //this line should only get called the first time but it gets called twice
if (!account) throw new Error(ERR.db)
}
<Suspense fallback="loading">
<Foo/>
<Suspense/>
<Suspense fallback="loading">
<Foo/>
<Suspense/>
If I remove the suspense it works as normal.
0 Replies
No replies yetBe the first to reply to this messageJoin