From b870e3447cd369d4ac5ed48f9468d4827ba46c51 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 is a regression of the fix 5fd3764ad8a2628e675bc05c4b6268edffd0dc26 --- lib/baseClient.js | 2 +- test/test.offset.js | 2 +- test/test.producer.js | 2 +- 3 files changed, 3 insertions(+), 3 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); }); }); diff --git a/test/test.producer.js b/test/test.producer.js index d554d167..305b57e6 100644 --- a/test/test.producer.js +++ b/test/test.producer.js @@ -46,7 +46,7 @@ var client, producer, noAckProducer, producerKeyed; producer.once('ready', callback); }, function (callback) { - producer.createTopics([EXISTS_TOPIC_3], true, callback); + producer.createTopics([EXISTS_TOPIC_3], false, callback); } ], done