couchdb-nano icon indicating copy to clipboard operation
couchdb-nano copied to clipboard

`changesReader` doesn't batch

Open andywillis opened this issue 3 years ago • 0 comments

Expected Behavior

I would expect the following code to wait 10 seconds and then return a batch of messages from the last position in the changes feed. So if I updated the DB 5 times within that 10 second timeout I would expect to see: "a batch of 5 changes has arrived" after 10 seconds.

messages.changesReader
  .start({ timeout: 10000 })
  .on('batch', (batch) => {
    console.log('a batch of', batch.length, 'changes has arrived');
  }).on('error', (e) => {
    console.error('error', e);
  });

Current Behavior

What is happening is that no batching is taking place. Every time I update the database within that timeout I immediately get the log "a batch of 1 changes has arrived".

Have I missed something obvious or misunderstood how nano's batching works?

Your Environment

  • Node v16.5
  • npm 8.5.5
  • Windows 10

andywillis avatar May 25 '22 15:05 andywillis