Skip to content

Preserve event error code - #1151

Merged
GaryWilber merged 2 commits into
Blizzard:masterfrom
zhangxin511:preserve-event-error-code
Oct 7, 2026
Merged

GaryWilber merged 2 commits into
Blizzard:masterfrom
zhangxin511:preserve-event-error-code

Conversation

@zhangxin511

Copy link
Copy Markdown
Contributor

event.error loses the numeric librdkafka error code (always -1)

EventDispatcher::Flush builds the JS error for EVENT_ERROR from the message text only, so LibrdKafkaError falls back to code = -1. A real ERR__ALL_BROKERS_DOWN (-187) or ERR__TRANSPORT (-195) arrives as code: -1, so code-based restart logic never matches.

Fix (small): keep event.err() / event.fatal() in event_t and set code and isFatal on the error object. lib/error.js already prefers a numeric e.code.

EventDispatcher::Flush created the JS error for EVENT_ERROR from the
message text only, so the librdkafka error code was lost. LibrdKafkaError
then fell back to code -1 (ERR_UNKNOWN) for every event.error, e.g.
ERR__ALL_BROKERS_DOWN (-187) and ERR__TRANSPORT (-195).

Keep event.err() and event.fatal() in event_t and set code and isFatal on
the error object. lib/error.js already prefers a numeric e.code, so no JS
change is needed.

Adds a test using a minimal fake broker: after librdkafka has learned a
real broker and it goes away, event.error must carry ERR__ALL_BROKERS_DOWN.
@GaryWilber
GaryWilber merged commit 73e6a1c into Blizzard:master Oct 7, 2026
9 checks passed
@zhangxin511
zhangxin511 deleted the preserve-event-error-code branch October 7, 2026 16:07
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