node-rdkafka icon indicating copy to clipboard operation
node-rdkafka copied to clipboard

Question: handling consumer stream errors gracefully (stream error, event.error)

Open MDSLKTR opened this issue 2 years ago • 0 comments

Assuming you are using the stream api for consumers a regular error event handler might look like this

this.consumerStream.on('error', error => {
                logger.error(
                    `[${this.name}]: Kafka consumer for topic: ${this.consumerOptions.topicName} caused stream error: ${error.message}`,
                    error,
                );
            });

What would be the proper comeback strategy from this? Do you need to check whether the error is fatal or not in (event.error)?. I am wondering how to handle these properly. In case the listener is not there a service would just crash with an uncaughtException. Any advise is much appreciated.

MDSLKTR avatar Apr 23 '24 13:04 MDSLKTR