Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

224
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!