From 5fd3764ad8a2628e675bc05c4b6268edffd0dc26 Mon Sep 17 00:00:00 2001 From: peteriman Date: Fri, 3 Jan 2020 20:17:43 +0800 Subject: [PATCH 1/3] Fixed isAsync params usage for createTopics --- lib/baseClient.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/baseClient.js b/lib/baseClient.js index 1c2ba246..31c7f76a 100644 --- a/lib/baseClient.js +++ b/lib/baseClient.js @@ -299,7 +299,7 @@ Client.prototype.createTopics = function (topics, isAsync, cb) { }); }); - if (!isAsync) { + if (isAsync) { cb(null); } }; From b7b1953de2e48ef11ffaaf7f3ae383e72d22887d Mon Sep 17 00:00:00 2001 From: peteriman Date: Sat, 4 Jan 2020 13:42:25 +0800 Subject: [PATCH 2/3] 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); }); }); From 8526b0bede5aeb9508fb8c4a3f05ce6f43bdfd94 Mon Sep 17 00:00:00 2001 From: peteriman Date: Sat, 4 Jan 2020 15:55:50 +0800 Subject: [PATCH 3/3] Reduced risk of collision by using uuid.v4() instead of Date.now() (To be consistent with test.highLevelProducer.js line 24) --- test/test.producer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test.producer.js b/test/test.producer.js index d554d167..04c2bd68 100644 --- a/test/test.producer.js +++ b/test/test.producer.js @@ -21,7 +21,7 @@ var client, producer, noAckProducer, producerKeyed; suiteTimeout: 30000 } ].forEach(function (testParameters) { - var TOPIC_POSTFIX = '_test_' + Date.now(); + var TOPIC_POSTFIX = '_test_' + uuid.v4(); var EXISTS_TOPIC_3 = '_exists_3' + TOPIC_POSTFIX; var sslOptions = testParameters.sslOptions;