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

117
Vistas
error handling with array of promises fails to return custom errors

I'm calling an async function which returns an array of promises to deal with the fact that eslint won't let you use await in a for loop...

my function is passing strings from an array one by one into another function which is doing some encoding and then waiting for them all to finish before returning the final encoded values as you can imagine a few things screw up on the encoding side and that module will throw relevant errors as needed

my issue is that unfortunately, when returning an array of promises those errors will not show on the stack trace... the only error that I get back is a generic 500 server error but none of my custom errors show

async function decodedAddresses(req, addresses) {
  if (!Array.isArray(addresses)) {
    return decodeId(req, addressId, idType.address);
  }

  return Promise.all(
    addresses.map(id => {
      return decoded(req, id).then(addr => {
        return {
          address: addr,
        };
      });
    })
  ).
  });
}

however if I simply call my function and have it return this way without the array of promises I have no issues and all the errors appear on the stack trace

async function decodedAddresses(req, addresses) {
return decoded(req, id)
}

also the length of the addresses does not matter it can be an array[1] or array[2] etc... the same issue occurs, I'm hoping someone might have some insight into why an array of promises may somehow be overwriting or not placing these errors on the stack

about 4 years ago · Juan Pablo Isaza
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