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

145
Visualizações
How does promise.all handle multiple API calls when one of them fails?

I had a question on how promise.all handles rejection.

Let's say we have the following command

await Promise.all([
  server1.logMessage(),
  server2.logMessage()
])

And let's say server1 takes 2secs to log and server2 takes 5secs to log.

And what happens if the server1.logMessage() returns a error in 1 sec. Can we be sure that server2 will at least log the message even though the resultant promise from promise.all is rejected?

Or do i need to use Promise.allSettled?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Yes, your promises look to be independent. Your code is equivalent to this:

const prom1 = server1.logMessage();
const prom2 = server2.logMessage();
await Promise.all([prom1, prom2])

All the Promise.all does is adjust the flow of the program in that block - it doesn't affect what either logMessage may or may not do. If one logMessage happens to log a message, or if it happens to error instead, that'll have no effect on what the other logMessage does.

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