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 fixes the regression from the fix 5fd3764.
  • Loading branch information
lamweili committed Jan 4, 2020
1 parent 5fd3764 commit b7b1953
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 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

0 comments on commit b7b1953

Please sign in to comment.