Skip to content

Commit

Permalink
Fix: requestTimeout bug (Request timed out after falsems) (#1253)
Browse files Browse the repository at this point in the history
  • Loading branch information
chosh31 committed Apr 30, 2019
1 parent ca179f1 commit ad8bed9
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/kafkaClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -993,19 +993,25 @@ KafkaClient.prototype.waitUntilReady = function (broker, callback) {

const onReady = () => {
logger.debug('broker is now ready');
this._clearTimeout(timeoutId);
timeoutId = null;

if (timeoutId !== null) {
this._clearTimeout(timeoutId);
timeoutId = null;
}

callback(null);
};

const timeout = this.options.requestTimeout;
const readyEventName = broker.getReadyEventName();

timeoutId = this._createTimeout(() => {
this.removeListener(readyEventName, onReady);
this._timeouts.delete(timeoutId);
callback(new TimeoutError(`Request timed out after ${timeout}ms`));
}, timeout);
// if (typeof timeout === 'boolean' && timeout !== false) {
timeoutId = this._createTimeout(() => {
this.removeListener(readyEventName, onReady);
this._timeouts.delete(timeoutId);
callback(new TimeoutError(`Request timed out after ${timeout}ms`));
}, timeout);
// }

this.once(readyEventName, onReady);
};
Expand Down

0 comments on commit ad8bed9

Please sign in to comment.