From bde1631c83e41d450fb115b900631f49ab5c49da Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Mon, 16 May 2022 14:50:07 +0300 Subject: [PATCH] Don't swallow indexing failures When an error occurs in the indexer pipeline, it logs it out, and then drops it on the floor. This is problematic because externally, from the task scheduler's perspective, it appears to have succeeded, which is not true. As a result, these failures are invisible to tooling which introspects over tasks. This makes the index task promise resolve when the pipeline finishes as before, but it rejects if the pipeline failed. Signed-off-by: Charles Lowell --- plugins/search-backend-node/src/IndexBuilder.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/search-backend-node/src/IndexBuilder.ts b/plugins/search-backend-node/src/IndexBuilder.ts index 235bac905a..2131c6937d 100644 --- a/plugins/search-backend-node/src/IndexBuilder.ts +++ b/plugins/search-backend-node/src/IndexBuilder.ts @@ -128,7 +128,7 @@ export class IndexBuilder { const indexer = await this.searchEngine.getIndexer(type); // Compose collator/decorators/indexer into a pipeline - return new Promise(done => { + return new Promise((resolve, reject) => { pipeline( [collator, ...decorators, indexer], (error: NodeJS.ErrnoException | null) => { @@ -136,12 +136,12 @@ export class IndexBuilder { this.logger.error( `Collating documents for ${type} failed: ${error}`, ); + reject(error); } else { + // Signal index pipeline completion! this.logger.info(`Collating documents for ${type} succeeded`); + resolve(); } - - // Signal index pipeline completion! - done(); }, ); });