SOHU-Co / kafka-node

Node.js client for Apache Kafka 0.8 and later.
MIT License
2.66k stars 628 forks source link

Uncaught exception when a kafka broker goes down #415

Closed tehdeadone closed 8 years ago

tehdeadone commented 8 years ago

I'm testing resilience on our app and I have both a producer and a consumer running. Pulling down one kafka broker at a time - I eventually hit this:

I don't have a one-off reproducible scenario but it comes up enough times to be a problem.

We're using v0.5.0 of kakfa-node on Kafka 0.9.0.1 and Zookeeper 3.4.8

ERROR - uncaughtException [TypeError: Cannot read property 'host' of undefined]
TypeError: Cannot read property 'host' of undefined
    at Client.lookupBrokerProfile (/usr/src/app/node_modules/kafka-node/lib/client.js:543:18)
    at Client.setupBroker (/usr/src/app/node_modules/kafka-node/lib/client.js:554:25)
    at Client.brokerForLeader (/usr/src/app/node_modules/kafka-node/lib/client.js:533:32)
    at Client.loadMetadataForTopics (/usr/src/app/node_modules/kafka-node/lib/client.js:263:21)
    at RetryOperation._fn (/usr/src/app/node_modules/kafka-node/lib/client.js:389:12)
    at RetryOperation.attempt (/usr/src/app/node_modules/retry/lib/retry_operation.js:56:8)
    at attemptRequestMetadata (/usr/src/app/node_modules/kafka-node/lib/client.js:387:15)
    at Client.refreshMetadata (/usr/src/app/node_modules/kafka-node/lib/client.js:383:3)
    at null.<anonymous> (/usr/src/app/node_modules/kafka-node/lib/consumer.js:84:10)
    at emitNone (events.js:85:20)
    at emit (events.js:179:7)
    at null._onTimeout (/usr/src/app/node_modules/kafka-node/lib/client.js:90:12)
    at tryOnTimeout (timers.js:224:11)
    at Timer.listOnTimeout (timers.js:198:5)
hyperlink commented 8 years ago

I may have fixed this for 0.5.1 however it's not published yet. Could you point package.json kafka-node to master (SOHU-Co/kafka-node) and see if this error shows?

tehdeadone commented 8 years ago

Sorry - didn't mean to close the issue. Will retry now and get back to you.

tehdeadone commented 8 years ago

I don't seem to see the error again. That's great. When will 0.5.1 be out?

hyperlink commented 8 years ago

Today.

hyperlink commented 8 years ago

@tehdeadone thanks for verifying the issue. 0.5.1 has been published to npm.

jbmusso commented 7 years ago

Greetings - Using v1.0.1 here, I'm also facing this issue when connecting a ConsumerGroup to a single-broker kafka cluster. When that single broker goes down, the Node.js process crashes with the following error:

/home/user/project/node_modules/kafka-node/lib/client.js:615
  addr = broker.host + ':' + broker.port;
               ^

TypeError: Cannot read property 'host' of undefined

Using docker images:

hyperlink commented 7 years ago

@jbmusso I pushed out a fix. Could you verify the latest v1.0.4 is working for you?