Skip to content

πŸ”– Bug Report β€” KafkaJS with Kafka 4.0.0 (KRaft) group coordinator issueΒ #1752

@adham-2002

Description

@adham-2002

Describe the bug
When running a KafkaJS consumer against a Kafka 4.0.0 (KRaft mode) broker, the consumer fails to join the group and repeatedly logs the error:

[Connection] Response GroupCoordinator(key: 10, version: 2) broker: localhost:29092 clientId: my-consumer error: The group coordinator is not available

This issue occurs when trying to auto-create the __consumer_offsets topic, which fails in KRaft mode, causing the consumer group coordination to be unavailable.


To Reproduce

Steps to reproduce the behavior:

  1. Set up a Kafka broker using apache/kafka:4.0.0 Docker image in KRaft mode
  2. Run a simple producer sending messages to a topic using KafkaJS
  3. Run a consumer with groupId using KafkaJS subscribing to that topic
  4. Observe the error in the consumer logs

Expected behavior
Consumer should successfully connect to the broker, join the group, and start consuming messages.


Observed behavior
Consumer keeps retrying to connect to the group coordinator and logs the following error repeatedly:

[Connection] Response GroupCoordinator(key: 10, version: 2) broker: localhost:29092 clientId: my-consumer error: The group coordinator is not available

And on the broker side:

Sent auto-creation request for Set(__consumer_offsets) to the active controller.
org.apache.kafka.common.network.InvalidReceiveException: Invalid receive (size = -720899)

Environment

  • OS: Ubuntu 22.04 (VMware)
  • KafkaJS version: 2.2.4
  • Kafka version: 4.0.0 (KRaft mode)
  • NodeJS version: 20.11.0
  • Docker: 25.0.3

Additional context
This issue seems to be related to the recent changes in Kafka 4.x KRaft mode group management and how KafkaJS interacts with the GroupCoordinator API.

Temporary workaround:
Downgrading Kafka to 3.6.1 resolves the issue as group management is compatible in that version.


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions