Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

105
Views
Firebase arrayRemove takes very long time in modular version

I'm refactoring my firebase code to support the modular firebase version.

After I refactored the "arrayRemove" function, I noticed that it started to take a very long time to execute. Something about 1 minute. At v8, that was about 1 seconds

Here is my code:

  const userRef = doc(db, 'users', userId)
  try {
    await updateDoc(userRef, {
      items: arrayRemove(itemId),
    })

    console.log('REMOVED')
  } catch (error) {
    console.log(error)
  }

Execution of this code takes around one minute. The same action with the same data in the same environment for the older version takes about one second. The rest functions works fast.

Firebase version: 9.6.1

Any ideas why it takes so long and how to make it faster?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

After reading article "Best Practices: Arrays in Firebase"

I found that practice:

to remove keys, we save the entire array instead of using .remove()

So... I removed item in my code, then updated array and it took less than a second!

  // removing item I need to remove at my local array
  const updArr = arr(
    (item) => item !== itemId
  )

  const userRef = doc(db, 'collection', 'id')

  // updating array
  await updateDoc(userRef, {
    gifts: updArr,
  })

// p.s. Obviously, there is some bug at arrayRemove function, but actually we don't have to use that function 🤫

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!