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

154
Visualizações
RxJS - Processing HTTPrequests in sequence

I'm currently trying to process HTTP Post requests in sequence, additionally trying to repeat each failed request until it succeeds (that is a requirement) and then and only then to continue with processing other requests. My code looks like this for now (it not working as it should, retryWhen is not used properly, I am aware of that, it's used just as a starting point reference):

...
subject
  .pipe(
    concatMap(async request => await this._sendPostRequest(request)),
    retryWhen(errors =>
      errors.pipe(
        tap(error => this._logger.error('error sending request', error)),
        delayWhen(() => timer(5000))
      )
    )
  )
  .subscribe();
...
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You're close!

Just attach your retry to the promise rather than the concatenated stream as a whole.

subject.pipe(     
  concatMap(request => defer(() => sendPostRequest(request)).pipe(           
    retryWhen(error$ => error$.pipe(               
      tap((error) => console.warn('error sending request', error)),               
      delay(1000)             
    ))         
  ))
).subscribe();
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