From 4fb7786f060fb4488f01d36f30cf7abc5817644e Mon Sep 17 00:00:00 2001 From: Maksym Mykhailenko Date: Thu, 31 Oct 2019 17:16:30 +0800 Subject: [PATCH] fix: error finally() is not a function This error was caused by calling finally() method on the promise returned by "async" function. "async" functions return native Promise which cannot be overwritten by "global.Promise = require('bluebird')", see https://github.com/petkaantonov/bluebird/issues/1434 for details. --- src/app.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app.js b/src/app.js index 638c41e..301231d 100644 --- a/src/app.js +++ b/src/app.js @@ -56,10 +56,14 @@ const dataHandler = (messageSet, topic, partition) => Promise.each(messageSet, ( throw new Error(`Invalid topic: ${topic}`) } })() - // commit offset regardless of errors - .then(() => {}) - .catch((err) => { logger.logFullError(err) }) - .finally(() => consumer.commitOffset({ topic, partition, offset: m.offset })) + .then(() => { + consumer.commitOffset({ topic, partition, offset: m.offset }) + }) + .catch((err) => { + logger.logFullError(err) + // commit offset regardless of errors + consumer.commitOffset({ topic, partition, offset: m.offset }) + }) }) /**