Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

108
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda