Closed bliu13 closed 3 months ago
I think I may have found two issues. I should disconnect when the produce.flush() callback is called. The code would look like this:
export async function flushedClose (producer) {
return new Promise((resolve, reject) => {
if (producer && producer.isConnected()) {
producer.flush(5000, (e) => {
if (e) {
return reject(e)
}
producer.disconnect(5000, (e, metrics) => {
if (e) {
return reject(e)
}
if (metrics) {
console.debug('Kafka disconnect metrics', metrics)
}
return resolve(metrics)
})
})
}
})
}
The second problem was that the function was simplified, and the timeouts were using environment variables and the values were not parsed into numbers.
Environment Information
Steps to Reproduce
When
producer.flush()
is called, the client crashes with the message:Here's a snippet of
getKafkaProducer.js
:node-rdkafka Configuration Settings
Additional context I followed the index.d.ts type definition for
flush
in theProducer
class: