`changesReader` doesn't batch
- Dominant language
- JavaScript
- Stars
- 689
- Forks
- 167
- Avg merge
- 1h
- Merged PRs (30d)
- 1
Description
## 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
Contributor guide
Research direction
Start by reproducing the supplied Node.js changesReader example with the stated timeout and update sequence. Trace the changesReader entry point to determine why each update emits a single-item batch; done means updates within the timeout produce one batch after the timeout, with errors still reported through the shown handler.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100