Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Kafka-Node Crashes Index Out of Range (client.js) #669

Closed
zach-snell opened this issue May 8, 2017 · 5 comments
Closed

Kafka-Node Crashes Index Out of Range (client.js) #669

zach-snell opened this issue May 8, 2017 · 5 comments
Labels

Comments

@zach-snell
Copy link

Bug Report

Kafka Node crashes after duration while idle (no in/out data flow).

Expected:
The application can run idle for infinite duration.

Actual:
Application is crashing while idle after a duration ranging from 5 mins to 2 hours.

Reproduction:
Spin up Kafka (I used docker spotify/kafka)
Generate a topic ( I created 2 with two attached producers, one console and one kafka-node. )
Connect with a consumer on a generated topic from kafka-node.
Idle until crash

Environment

  • Node version: v6.9.4
  • Kafka-node version: v1.6.0
  • Kafka version: 2.11-0.10.1.0

For specific cases also provide

(using docker spotify/kafka)

  • Number of Brokers: default
  • Number partitions for topic: default

Include Sample Code to reproduce behavior

This issue occurs after a random idle duration between 5 mins and 120 mins

Focusing on this code:

Client.prototype.handleReceivedData = function (socket) {
  var buffer = socket.buffer;
  if (!buffer.length) {
    return;
  }
  // Watch for a buffer to come through as readUInt8
  var size = buffer.readUInt32BE(0) + 4; // EXCEPTION, index out of bounds (I think due to there being no UInt32 in the _buffs of the buffer
  ...

}

Include output with Debug turned on

RangeError: Index out of range
at checkOffset (buffer.js:817:11)
at Buffer.readUInt32BE (buffer.js:891:5)
at BufferList.(anonymous function) [as readUInt32BE] (/Users/zachsnell/develop/realm-event-handler-poc/node_modules/bl/bl.js:273:58)
at Client.handleReceivedData (/Users/zachsnell/develop/realm-event-handler-poc/node_modules/kafka-node/lib/client.js:735:21)
at Socket. (/Users/zachsnell/develop/realm-event-handler-poc/node_modules/kafka-node/lib/client.js:700:10)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:548:20)

@hyperlink
Copy link
Collaborator

Looks like you're using 1.6.1 since it's using buffer list. Does this happen with 1.6.0?

@zach-snell
Copy link
Author

@hyperlink You are right, I very lazily added this to my package.json and allowed the newer version. I will try with 1.6.0 and let you know the result.

Thanks!

@hyperlink hyperlink added the bug label May 8, 2017
@hyperlink
Copy link
Collaborator

btw I'm working on 1.6.2 release with those breaking changes reverted.

@hyperlink
Copy link
Collaborator

Published as 1.6.2

hyperlink added a commit that referenced this issue May 8, 2017
hyperlink added a commit that referenced this issue May 8, 2017
* Revert "Fix #669 by revert bl change (#670)"

This reverts commit b77c199.

* Fix out of range exception when consumer idle
@crzidea
Copy link
Member

crzidea commented May 9, 2017

OK, I get it! The condition should not be !buffer.length, it should be buffer.length < 4. @hyperlink There is no need to revert the bl change completely.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants