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

142
Vistas
Do I need to keep a reference to a JS promise chain?

In modern Javascript, if I build up a sequence of actions inside promise.then(...).catch(...), but I don't care about the result, nor do I need to wait for the sequence to finish, but I do want it to finish, do I need to keep a reference to the resulting Promise? Is there a danger that it might be garbage-collected and never run to completion if I don't keep a reference to it alive?

If the answer is "this is implementation-dependent," that's disappointing. But I'd be especially interested to know how recent versions of V8 (≥ 9.5) handle this.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Do I need to keep a reference to a JS promise chain?

No, you do not. The promise chain will run to completion whether you save the promise or not.

Things are only garbage collected when they are no longer referenced by any active code. A promise that represents an active asynchronous operation is still being referenced by that asynchronous operation until that asynchronous operation is actually complete (since the asynchronous operation has the ability to resolve or reject the promise). So, promises won't be eligible for garbage collection until the operations they are connected to are done.

This is not implementation-dependent. The garbage collector cannot collect objects that are still in use. Everything would break if that was the case. Once the promise is no longer in use, then garbage collecting it has no affect on any running code.

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