message-hub-rest
message-hub-rest copied to clipboard
ConsumerInstance.prototype.get: Promise caching error
ConsumerIntances.prototype.get has a caching method when there is a pending promise for a given topic.
When this method is queried several times, only the first promise has the correct output, the following ones have incorrect responses.
Example:
const MessageHub = require('message-hub-rest');
const instance = new MessageHub(config);
instance
.consume('a-nice-group', 'a-nice-id', {'auto.offset.reset': 'largest'})
.then(consumers => consumers[0])
.then(consumer => {
consumer.get('topic').then(d => console.log(d));
// Outputs: `[]`
consumer.get('topic').then(d => console.log(d));
// Outputs: `{ '0': [] }`
consumer.get('topic').then(d => console.log(d));
// Outputs: `{ '0': [] }`
});
This PR fixes this issue.