Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

114
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda