Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Error when kafka topic has more than one partition #174

Open
cferrera opened this issue Feb 21, 2022 · 0 comments
Open

Error when kafka topic has more than one partition #174

cferrera opened this issue Feb 21, 2022 · 0 comments

Comments

@cferrera
Copy link

Hello!

I'm facing the following error when I try to produce a message to a kafka topic that has more than one partition. I've tried the exactly code on topics with 1, 2, 3 and 4 partitions and it only works for topics with 1 partition.

TypeError: Cannot read property 'v3' of undefined
    at JSProducer._murmur (~/node_modules/sinek/dist/lib/kafkajs/JSProducer.js:108:77)
    at JSProducer._getPartitionForKey (~/node_modules/sinek/dist/lib/kafkajs/JSProducer.js:206:21)
    at JSProducer.<anonymous> (~/node_modules/sinek/dist/lib/kafkajs/JSProducer.js:254:34)
    at Generator.next (<anonymous>)
    at fulfilled (~/node_modules/sinek/dist/lib/kafkajs/JSProducer.js:5:58)

I was able to track the issue a little bit:

This is the piece where the code breaks:

case "3":
  this._murmur = (key, partitionCount) => murmurhash_1.murmur.v3(key) % partitionCount;
  break;

it states that "murmur" is undefined. Removing "murmur" from the call - leaving only murmurhash_1.v3(key) - it works just fine. 👌

Going into a little further into murmurhash package, we can find this, a conditional on how the value will be exported.

I don't know when a module has type undefined but on every test that I did it was always a typeof object.

Going back to JSProducer, replacing this:

import { murmur } from "murmurhash";

with this

 import * as murmur from "murmurhash"; 

worked for me.

Not sure if anyone else has the same issue or if I'm doing something wrong but please let me know, other than that, if this replace sounds correct, will be a pleasure to contribute with a PR.

Thanks in advance. ✌️

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

No branches or pull requests

1 participant