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

Prevent typeerror when committing offsets for a topic before initialization #1235

Merged
merged 2 commits into from
Nov 22, 2021

Conversation

Nevon
Copy link
Collaborator

@Nevon Nevon commented Nov 22, 2021

I cannot reproduce this myself, but I have seen a service somehow triggering this in production. I think it's triggered somehow when trying to commit offsets for a topic before the consumer has gone through the fetch loop, or maybe something to do with them using a different consumer instance to commit than they are using to consume. This application is basically storing references to consumers in a lookup table, and replacing the consumers whenever there's any error, which means that they might be calling consumer.commitOffsets while the consumer is somewhere in the middle of joining the group or in the middle of shutting down etc. Clearly they shouldn't do that, but any which way KafkaJS shouldn't throw a TypeError here.

The code is assuming that committedOffsets()[topic] will always return an object, but in some weird circumstance that's not the case, so it throws a TypeError from trying to do Object.assign(undefined, offsets).

@Nevon Nevon requested a review from tulios November 22, 2021 08:53
…zation

`committedOffsets()[topic]` can return undefined in some circumstances.
@Nevon Nevon merged commit ade1932 into master Nov 22, 2021
@Nevon Nevon deleted the commit-offsets-typeerror branch November 22, 2021 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant