Skip to content

fix: broker sends error response instead of dropping connection#133

Merged
kamir merged 1 commit intoKafScale:mainfrom
kamir:fix/broker-error-response
Mar 9, 2026
Merged

fix: broker sends error response instead of dropping connection#133
kamir merged 1 commit intoKafScale:mainfrom
kamir:fix/broker-error-response

Conversation

@kamir
Copy link
Collaborator

@kamir kamir commented Mar 5, 2026

Summary

  • Broker no longer drops TCP connections on handler errors. Previously, any handler error (e.g., unsupported Fetch version) caused handleConnection to close the connection — clients saw EOF. Now the broker constructs a minimal Kafka error response via kmsg.ResponseForKey and keeps the connection alive.
  • Removed the Fetch v11 minimum version check. The broker rejected Fetch requests below v11, which caused EOF for clients negotiating older versions (e.g., segmentio/kafka-go). Since kmsg handles all Fetch versions natively, the floor was unnecessary.
  • Fixes "fetching message: EOF" errors observed in KafClaw and other consumer applications using segmentio/kafka-go or franz-go.

Changed files

File Change
pkg/broker/server.go handleConnection sends error response + continue instead of return; adds buildErrorResponse helper
pkg/broker/server_test.go Adds comprehensive server tests; TestServerHandleConnection_HandlerError verifies error response is sent instead of connection close
cmd/broker/main.go Removes APIVersion < 11 guard in handleFetch

Test plan

  • go test ./pkg/broker/ passes — updated test verifies error response is sent
  • go test ./cmd/broker/ passes
  • go test ./... passes — no regressions

🤖 Generated with Claude Code

…ndler errors

Previously, when a handler returned an error (e.g., unsupported Fetch
version), the broker closed the TCP connection causing clients to see
EOF. Now the broker constructs a minimal Kafka error response via
kmsg.ResponseForKey and keeps the connection alive.

Also removes the Fetch v11 minimum version check — kmsg handles all
versions natively, so the broker can serve Fetch v0+ requests. This
fixes "fetching message: EOF" errors seen with clients like
segmentio/kafka-go or franz-go.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Collaborator

@klaudworks klaudworks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

@kamir kamir merged commit 3f575ae into KafScale:main Mar 9, 2026
9 checks passed
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.

2 participants