Skip to content

Commit

Permalink
Fixes #531 unhandled error in Offset
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperlink committed Jan 3, 2017
1 parent 2876902 commit cfe23cb
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions lib/offset.js
Expand Up @@ -63,18 +63,15 @@ Offset.prototype.fetchCommits = function (groupId, payloads, cb) {

Offset.prototype.fetchLatestOffsets = function (topics, cb) {
if (!this.ready) {
setTimeout(function () {
this.fetchLatestOffsets(topics, cb);
}.bind(this), 100);
setTimeout(() => this.fetchLatestOffsets(topics, cb), 100);
return;
}

var client = this.client;
async.waterfall([
function (callback) {
client.loadMetadataForTopics(topics, callback);
callback => {
this.client.loadMetadataForTopics(topics, callback);
},
function (topicsMetaData, callback) {
(topicsMetaData, callback) => {
var payloads = [];
var metaDatas = topicsMetaData[1].metadata;
Object.keys(metaDatas).forEach(function (topicName) {
Expand All @@ -87,9 +84,7 @@ Offset.prototype.fetchLatestOffsets = function (topics, cb) {
});
});
});

var offset = new Offset(client);
offset.fetch(payloads, callback);
this.fetch(payloads, callback);
},
function (results, callback) {
Object.keys(results).forEach(function (topicName) {
Expand Down

0 comments on commit cfe23cb

Please sign in to comment.