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

223
Visualizações
Eventstore client for NodeJs(@eventstore/db-client) stops the execution when 'maxCount' for reading the events from stream is increased more than 20

The program run fines when I have the following configuration:

let events = eventstoreClient.readStream(
       streamName,
       {
         fromRevision: END,
         direction: BACKWARDS,
         maxCount: 20
       }
     );

However, the program stucks(i.e. could not read the streams/events further) when maxCount is set to 100 or 1000 or maxCount option is not supplied!

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

0

readStream returns a readable stream which will buffer the events internally until they exceed the highWaterMark threshold. The data will sit in the internal queue until it is consumed, and the stream will temporarily stop reading events from the server until the data currently buffered has been consumed.

When you request 20 events they fit within internal buffer, so after 20 events the stream closes and NodeJS is happy to stop execution. However, if you request 100 or 1000 events, once the internal buffer is full, the stream won't be closed as there are still events to be read from the server, and it will wait for you to consume those events.

You need to pull the events from the buffer to allow the streaming read to finish. This can be done in a number of ways, for example:

Iterate through the steam:

for await (const { event } of events) {
  console.log(event);
}

or add an event listener:

events.on("data", (event) => {
  console.log(event);
});

You can read more about buffering here: https://nodejs.org/api/stream.html#buffering

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