move wait into try block

Signed-off-by: Brian Fletcher <brian@roadie.io>
This commit is contained in:
Brian Fletcher
2022-11-17 11:08:10 +00:00
parent a962ce0551
commit 1bbe66c27b
@@ -110,12 +110,13 @@ 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 {
const maybeError = await this.initialized;
if (maybeError) {
done(maybeError);
return;
}
// Index any remaining documents.
if (this.currentBatch.length) {
await this.index(this.currentBatch);