Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TLDR
In version 2.0.1, most
consumer.seek()
calls are broken if more than one partition is used. This PR fixes the underlying issue.Detailed explanation & way to reproduce:
After upgrading kafkajs to version 2.0.1 in our application, a test suddenly failed to pass.
Initially, this test does the following:
setOffsets(...)
However, this fails (in a reproducible way) because the third operation sets the offset not for partition 1, but partition 0 instead. Further investigations of the bug lead me to the conclusion that the issue must lie somewhere within the consumer seek logic, as the internal
consumer.seek()
call withinsetOffsets
passed the correct partition information. I encountered the updatedSeekOffsets
data structure eventually and found two issues:pop(TOPIC, 0)
, which happened beforepop(TOPIC, 1)
, returned the offset for partition 1 instead of 0, and removed it.pop(topic, partition)
returns a non-undefined object (with undefined topic and partition) as soon as ANY topic or partition offset information is stored. I didn't investigate in how far this would affect the seek call inconsumerGroup.js
line 662, but I guess it is not how it should be called.