Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could KafkaJSProtocolError please report what topic it fails for? #1176

Closed
olivierlacan opened this issue Aug 26, 2021 · 1 comment
Closed

Comments

@olivierlacan
Copy link

Currently when this error occurs when attempting to consume from a non-existent topic, it's incredibly difficult to figure out what topic is causing the actual issue (especially if you consume a lot of different topics):

UnhandledPromiseRejectionWarning: KafkaJSProtocolError: This server does not host this topic-partition
``

I'd be much easier to debug these exceptions if they instead provided more context: 

UnhandledPromiseRejectionWarning: KafkaJSProtocolError: This server does not host this topic-partition: namespace.v1.Topic


That change alone could have saved my team hours of debugging. We expected one topic to be the culprit and it in fact was another.

**Additional context**

I've looked in [errors.js](https://github.com/tulios/kafkajs/blob/9b5ef7f7961fdb6716e2e90634b36abb81d24af9/src/errors.js#L22-L29) and it seems like it would possible to add `topic = null` as an option in the second argument object and then do something like: 

```javascript
class KafkaJSProtocolError extends KafkaJSError {
  constructor(e, { retriable = e.retriable, topic = null } = {}) {
    super(e, { retriable })
    this.message = e.message
    (topic !== null) ? this.message += (": " + topic)
    this.type = e.type
    this.code = e.code
    this.name = 'KafkaJSProtocolError'
  }
}

This is a quick POC and I don't really know where the topic could be sent a KafkaJSProtocolError instance but I'd gladly take some guidance and open a PR if that seems reasonable.

@Nevon
Copy link
Collaborator

Nevon commented Mar 9, 2022

Duplicate of #957. See this comment for a proposal on how to enhance this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants