Skip to content

Log Kafka consumer close errors#426

Merged
kjamrog merged 3 commits intomainfrom
improve_error_observability_on_kafka_consumer_close
Apr 20, 2026
Merged

Log Kafka consumer close errors#426
kjamrog merged 3 commits intomainfrom
improve_error_observability_on_kafka_consumer_close

Conversation

@kjamrog
Copy link
Copy Markdown
Collaborator

@kjamrog kjamrog commented Apr 20, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced error handling during Kafka consumer shutdown to capture, log, and report errors that previously went unnoticed. Errors are now properly recorded with diagnostic information and reported through the system's error reporting mechanism, significantly improving observability and troubleshooting capabilities when consumer connections fail to close or encounter issues during termination.

@kjamrog kjamrog requested a review from CarlosGamero April 20, 2026 11:19
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

Warning

Rate limit exceeded

@kjamrog has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 54 minutes and 43 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 54 minutes and 43 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 34436bb7-07b3-4d31-b890-92397984ad6f

📥 Commits

Reviewing files that changed from the base of the PR and between 147316b and 378f87c.

📒 Files selected for processing (1)
  • packages/kafka/lib/AbstractKafkaConsumer.ts
📝 Walkthrough

Walkthrough

The Kafka consumer's close() method now catches and handles errors from consumer closure by logging warnings and reporting errors through the error reporter, rather than silently ignoring them.

Changes

Cohort / File(s) Summary
Kafka Consumer Error Handling
packages/kafka/lib/AbstractKafkaConsumer.ts
Enhanced error handling in close() method to catch exceptions from consumer.close(), log warnings via resolveGlobalErrorLogObject(), and report errors through the error reporter before clearing the consumer instance.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • PR #418: Modifies Kafka error reporting to use resolveGlobalErrorLogObject and report errors via errorReporter in another Kafka service method.
  • PR #419: Directly related change to AbstractKafkaConsumer.close() error handling with similar error catching and reporting patterns.

Suggested labels

patch

Suggested reviewers

  • kibertoad

Poem

🐰 A consumer closes with grace,
Errors caught without a trace,
Warnings logged for all to see,
No silent faults can sneak through me! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Log Kafka consumer close errors' directly and clearly describes the main change: adding error logging to the Kafka consumer's close() method.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch improve_error_observability_on_kafka_consumer_close

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/kafka/lib/AbstractKafkaConsumer.ts`:
- Around line 243-248: The close-failure reporter call in
AbstractKafkaConsumer.ts currently replaces non-Error throwables with a generic
Error and drops the original resolved log details; update the catch block around
this.logger.warn to pass the resolved log object (from
resolveGlobalErrorLogObject(err)) into errorReporter.report as context (for both
Error and non-Error cases) and keep reporting the actual Error when isError(err)
is true (e.g., error: err) while adding a context: resolvedLogObject property so
the reporter retains the original payload and matches the sibling service
pattern.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 492c7886-a5a9-4ae5-9569-102f5898e756

📥 Commits

Reviewing files that changed from the base of the PR and between b33b6ee and 147316b.

📒 Files selected for processing (1)
  • packages/kafka/lib/AbstractKafkaConsumer.ts

Comment thread packages/kafka/lib/AbstractKafkaConsumer.ts
@kjamrog kjamrog added the patch label Apr 20, 2026
@kjamrog kjamrog merged commit dc0c673 into main Apr 20, 2026
15 of 18 checks passed
@kjamrog kjamrog deleted the improve_error_observability_on_kafka_consumer_close branch April 20, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants