From 91fb99c69fe864091c716ad7e8d827d890eac91f Mon Sep 17 00:00:00 2001 From: Jared <51723690+jaredbarranco@users.noreply.github.com> Date: Fri, 3 Jan 2025 15:15:58 -0800 Subject: [PATCH] bugfix: pass meta to existsIndexTemplate method from OS API (#2) Signed-off-by: barrancojared Signed-off-by: barrancojared <51723690+jaredbarranco@users.noreply.github.com> --- bulk_writer.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bulk_writer.js b/bulk_writer.js index 8e9674c..8ef23f3 100644 --- a/bulk_writer.js +++ b/bulk_writer.js @@ -19,11 +19,14 @@ const BulkWriter = function BulkWriter(transport, client, options) { this.bulk = []; // bulk to be flushed this.running = false; this.timer = false; + this.connected = false; debug('created', this); }; BulkWriter.prototype.start = function start() { - this.checkEsConnection(this.retryLimit); + this.checkEsConnection(this.retryLimit).finally(() => { + this.connected = true; + }); debug('started'); }; @@ -104,7 +107,7 @@ BulkWriter.prototype.append = function append(index, doc) { attempts: 0, }); // resume the buffering process - if (!this.running) { + if (!this.running && this.connected) { this.running = true; this.tick(); } @@ -251,7 +254,7 @@ BulkWriter.prototype.ensureIndexTemplate = function ensureIndexTemplate(fulfill, name: 'template_' + templateName, }; debug('Checking tpl name', tmplCheckMessage); - thiz.client.indices.existsIndexTemplate(tmplCheckMessage).then( + thiz.client.indices.existsIndexTemplate(tmplCheckMessage, { meta: true }).then( (res) => { if (res.statusCode && res.statusCode === 404) { const tmplMessage = {