Skip to content

Commit

Permalink
fix: avoid passing on an empty buffer in finish callback
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Oct 30, 2023
1 parent a70905f commit e0fbe8e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/_index-queue.js
Expand Up @@ -109,9 +109,14 @@ export default function indexQueueFactory({
}
},
finish: () => {
ingest(buffer);
finished = true;
buffer = [];

if (buffer.length > 0) {
ingest(buffer);
buffer = [];
} else if (queue.length === 0 && ingesting === 0) {
queueEmitter.emit('finish');
}
},
queueEmitter,
};
Expand Down

0 comments on commit e0fbe8e

Please sign in to comment.