Blizzard / Blizzard/node-rdkafka
node-rdkafka throwing Segmentation fault for node 18 and 20 for docker and mac os
- Dominant language
- JavaScript
- Stars
- 2.2k
- Forks
- 403
- PR merge metrics
- No merged PRs in 30d
Description
**Environment Information**
- OS [e.g. Mac, Arch, Windows 10]: docker/mac
- Node Version [e.g. 8.2.1]: 18 an 20
- NPM Version [e.g. 5.4.2]: 8.5.5
- C++ Toolchain [e.g. Visual Studio, llvm, g++]:
- node-rdkafka version [e.g. 2.3.3]: 2.16.9
**Steps to Reproduce**
RUN below code in docker/mac
`
/* Copyright (c) Microsoft Corporation. All rights reserved.
* Copyright (c) 2016 Blizzard Entertainment
* Licensed under the MIT License.
*
* Original Blizzard node-rdkafka sample modified for use with Azure Event Hubs for Apache Kafka Ecosystems
*/
var Kafka = require('node-rdkafka');
var producer = new Kafka.Producer({
//'debug' : 'all',
'metadata.broker.list': 'mynamespace.servicebus.windows.net:9093', //REPLACE
'dr_cb': true, //delivery report callback
'security.protocol': 'SASL_SSL',
'sasl.mechanisms': 'PLAIN',
'sasl.username': '$ConnectionString', //do not replace $ConnectionString
'sasl.password': 'Endpoint=sb://mynamespace.servicebus.windows.net/;SharedAccessKeyName=XXXXXX;SharedAccessKey=XXXXXX' //REPLACE
});
var topicName = 'test';
//logging debug messages, if debug is enabled
producer.on('event.log', function(log) {
console.log(log);
});
//logging all errors
producer.on('event.error', function(err) {
console.error('Error from producer');
console.error(err);
});
//counter to stop this sample after maxMessages are sent
var counter = 0;
var maxMessages = 10;
producer.on('delivery-report', function(err, report) {
console.log('delivery-report: ' + JSON.stringify(report));
counter++;
});
//Wait for the ready event before producing
producer.on('ready', function(arg) {
console.log('producer ready.' + JSON.stringify(arg));
for (var i = 0; i < maxMessages; i++) {
var value = new Buffer(`{"name" : "person${i}"}"`);
var key = "key-"+i;
// if partition is set to -1, librdkafka will use the default partitioner
var partition = -1;
producer.produce(topicName, partition, value, key);
}
//need to keep polling for a while to ensure the delivery reports are received
var pollLoop = setInterval(function() {
producer.poll();
if (counter === maxMessages) {
clearInterval(pollLoop);
producer.disconnect();
}
}, 1000);
});
producer.on('disconnected', function(arg) {
console.log('producer disconnected. ' + JSON.stringify(arg));
});
//starting the producer
producer.connect();
`
**node-rdkafka Configuration Settings**
**Additional context**
Contributor guide
Research direction
Start with the supplied node-rdkafka producer sample and run it under Node 18 and 20 in the reported Docker and macOS environments. Confirm whether producer.connect() and the produce loop reproduce the segmentation fault, then investigate the node-rdkafka and librdkafka compatibility involved. Done means the sample runs without a segmentation fault and still receives delivery reports.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, javascript, nodejs
- Domain
- backend, devops, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100