wait for initialize to complete before finalize

Signed-off-by: Brian Fletcher <brian@roadie.io>
This commit is contained in:
Brian Fletcher
2022-11-16 14:03:56 +00:00
parent 3462f25ef7
commit a962ce0551
2 changed files with 10 additions and 0 deletions
@@ -110,6 +110,11 @@ export abstract class BatchSearchEngineIndexer extends Writable {
* @internal
*/
async _final(done: (error?: Error | null) => void) {
const maybeError = await this.initialized;
if (maybeError) {
done(maybeError);
return;
}
try {
// Index any remaining documents.
if (this.currentBatch.length) {