Blizzard / node-rdkafka

Node.js bindings for librdkafka
MIT License
2.08k stars 391 forks source link

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

Open MDSLKTR opened 2 months ago

MDSLKTR commented 2 months ago

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.