Skip to content

Commit

Permalink
Defaults createTopics' param async=false
Browse files Browse the repository at this point in the history
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 5fd3764
  • Loading branch information
lamweili committed Jan 4, 2020
1 parent 5fd3764 commit b870e34
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/baseClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion test/test.offset.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/test.producer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b870e34

Please sign in to comment.