Blizzard / node-rdkafka

Node.js bindings for librdkafka
MIT License
2.1k stars 390 forks source link

Buffer header values converted to strings #1006

Open tleasure opened 1 year ago

tleasure commented 1 year ago

Environment Information

Steps to Reproduce Run attached test script. It will crash, trying to do a readInt32LE() operation on the Buffer due to it being previously converted to a string value.

node-rdkafka Configuration Settings see script

Additional context The issue is resolved when applying PR #968. Sample file to reproduce: test.js.txt

Output from 2.15.0 module

rebalance_cb called
running producer...
data.value: test-payload-value
[ { myID: <Buffer 43 02> } ]
node:internal/buffer:84
    throw new ERR_BUFFER_OUT_OF_BOUNDS();
    ^

RangeError [ERR_BUFFER_OUT_OF_BOUNDS]: Attempt to access memory outside buffer bounds
    at new NodeError (node:internal/errors:372:5)
    at boundsError (node:internal/buffer:84:11)
    at Uint8Array.readInt32LE (node:internal/buffer:390:5)
    at KafkaConsumer.<anonymous> (test.js:38:39)
    at KafkaConsumer.emit (node:events:527:28)
    at readCallback (./node_modules/node-rdkafka/lib/kafka-consumer.js:448:12) {
  code: 'ERR_BUFFER_OUT_OF_BOUNDS'
}

Output from patched module

rebalance_cb called
running producer...
data.value: test-payload-value
[ { myID: <Buffer 43 02 00 00> } ]
myIDVal should be 579: 579
myIDVal type should be 'number': number