confluentinc / confluentinc/confluent-kafka-javascript

Request: more context in errors reported to logger, specifically 'Unknown topic or partition'

Open
#239 5 comments 0 reactions 0 assignees View on GitHub
status:waiting-for-interest
Dominant language
TypeScript
Stars
304
Forks
45
Avg merge
11h 47m
Merged PRs (30d)
5

Description

**Environment Information**

- OS: Mac M3 Sonoma 14.6.1
- Node Version: 20.14.0
- NPM Version: 10.7.0
- confluent-kafka-javascript version: 1.0.0

**Steps to Reproduce**

In general the errors sent to the logger often lack some critical context that would make the source easy to identify.

In our case we have an application that is spinning up consumers for dozens of topics from different components. The following is an example error for a recent issue as received in the logger:

```json
{
"message": "Consumer encountered error while consuming. Retrying. Error details: KafkaJSProtocolError: Broker: Unknown topic or partition : Error: Broker: Unknown topic or partition\n at Function.createLibrdkafkaError [as create] (/Users/peloquina/src/agilysys-inc/stay/backplane-base/node_modules/@confluentinc/kafka-javascript/lib/error.js:459:10)\n at /Users/peloquina/src/agilysys-inc/stay/backplane-base/node_modules/@confluentinc/kafka-javascript/lib/kafka-consumer.js:557:29\n at callbackTrampoline (node:internal/async_hooks:130:17)",
"extras": {
"name": "Confluent#consumer-6",
"fac": "BINDING",
"timestamp": 1736870741813
}
}
```
If the `extras` included the topic name in this case, it would have saved hours spent narrowing down which consumer was actually at fault.

The `name` value seems like it should be a useful cross-reference, but as it a `#` private field on the consumer it can only be associated with other log entries and is completely inaccessible from within our application.

![Image](https://github.com/user-attachments/assets/3cea29e0-d536-448e-8b5f-65520cc45439)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.