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

Error while producing messages #359

Closed
cantidio opened this issue Apr 29, 2016 · 0 comments · Fixed by #360
Closed

Error while producing messages #359

cantidio opened this issue Apr 29, 2016 · 0 comments · Fixed by #360

Comments

@cantidio
Copy link
Contributor

It seems the value is undefined and is not being catched by the code before it, which checks for null only.

if (value !== null) { // <===== here
        if (Buffer.isBuffer(value)) {
            m.Int32BE(value.length);
        } else {
            if (typeof value !== 'string') value = value.toString();
            m.Int32BE(Buffer.byteLength(value));
        }
        m.string(value);
    } else {
        m.Int32BE(-1);
    }

This results on this error when I run the example provided on the readme.

/Users/cantidio/Projects/node-kafka-rx/node_modules/kafka-node/lib/protocol/protocol.js:385
            if (typeof value !== 'string') value = value.toString();
                                                        ^

TypeError: Cannot read property 'toString' of undefined
    at encodeMessage (/Users/cantidio/Projects/node-kafka-rx/node_modules/kafka-node/lib/protocol/protocol.js:385:57)
    at /Users/cantidio/Projects/node-kafka-rx/node_modules/kafka-node/lib/protocol/protocol.js:358:19
    at Array.forEach (native)
    at encodeMessageSet (/Users/cantidio/Projects/node-kafka-rx/node_modules/kafka-node/lib/protocol/protocol.js:357:16)
    at /Users/cantidio/Projects/node-kafka-rx/node_modules/kafka-node/lib/protocol/protocol.js:345:30
    at Array.forEach (native)
    at /Users/cantidio/Projects/node-kafka-rx/node_modules/kafka-node/lib/protocol/protocol.js:344:14
    at Array.forEach (native)
    at _encodeProduceRequest (/Users/cantidio/Projects/node-kafka-rx/node_modules/kafka-node/lib/protocol/protocol.js:338:12)
    at /Users/cantidio/Projects/node-kafka-rx/node_modules/kafka-node/lib/protocol/protocol.js:326:16

When I fixed this check, everything works as expected.

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

Successfully merging a pull request may close this issue.

1 participant