From b7b1953de2e48ef11ffaaf7f3ae383e72d22887d Mon Sep 17 00:00:00 2001 From: peteriman Date: Sat, 4 Jan 2020 13:42:25 +0800 Subject: [PATCH] Defaults createTopics' param async=false Async must default to false. It is dangerous to use async=true for createTopics unless explicitly specified. For running async calls, the subsequent steps (such as addTopics) will fail as the topics are yet to be created/in the progress of creation. It is the nature of async to return immediately even before the createTopics is completed. This fixes the regression from the fix 5fd3764ad8a2628e675bc05c4b6268edffd0dc26. --- lib/baseClient.js | 2 +- test/test.offset.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/baseClient.js b/lib/baseClient.js index 31c7f76a..aeb97038 100644 --- a/lib/baseClient.js +++ b/lib/baseClient.js @@ -253,7 +253,7 @@ Client.prototype.createTopics = function (topics, isAsync, cb) { if (typeof isAsync === 'function' && typeof cb === 'undefined') { cb = isAsync; - isAsync = true; + isAsync = false; } try { diff --git a/test/test.offset.js b/test/test.offset.js index 98aaec4f..f77f6f97 100644 --- a/test/test.offset.js +++ b/test/test.offset.js @@ -14,7 +14,7 @@ describe('Offset', function () { client = new Client(); producer = new Producer(client); producer.on('ready', function () { - producer.createTopics(['_exist_topic_3_test'], true, function (err) { + producer.createTopics(['_exist_topic_3_test'], false, function (err) { done(err); }); });