From 48a0ee617f5b713cef6b27fdc807ade3752f471f Mon Sep 17 00:00:00 2001 From: Roberto Bianchi Date: Thu, 19 Dec 2024 19:29:04 +0100 Subject: [PATCH] chore(node): repro crash Signed-off-by: Roberto Bianchi --- fastify2/package-lock.json | 36 ++++++++++++++++++++++++++++++++++++ fastify2/package.json | 3 ++- fastify2/server.js | 18 ++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/fastify2/package-lock.json b/fastify2/package-lock.json index dd2d97e..7ba6cff 100644 --- a/fastify2/package-lock.json +++ b/fastify2/package-lock.json @@ -7,6 +7,7 @@ "dependencies": { "@platformatic/node": "^2.26.1", "fastify": "^5.1.0", + "node-rdkafka": "3.2.1", "undici": "^6.20.1" } }, @@ -1510,6 +1511,15 @@ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "license": "MIT" }, + "node_modules/bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "license": "MIT", + "dependencies": { + "file-uri-to-path": "1.0.0" + } + }, "node_modules/bintrees": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/bintrees/-/bintrees-1.0.2.tgz", @@ -1881,6 +1891,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "license": "MIT" + }, "node_modules/find-my-way": { "version": "9.1.0", "resolved": "https://registry.npmjs.org/find-my-way/-/find-my-way-9.1.0.tgz", @@ -2182,6 +2198,12 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "license": "MIT" }, + "node_modules/nan": { + "version": "2.22.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.22.0.tgz", + "integrity": "sha512-nbajikzWTMwsW+eSsNm3QwlOs7het9gGJU5dDZzRTQGk03vyBOauxgI4VakDzE0PtsGTmXPsXTbbjVhRwR5mpw==", + "license": "MIT" + }, "node_modules/node-addon-api": { "version": "8.3.0", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.3.0.tgz", @@ -2191,6 +2213,20 @@ "node": "^18 || ^20 || >= 21" } }, + "node_modules/node-rdkafka": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/node-rdkafka/-/node-rdkafka-3.2.1.tgz", + "integrity": "sha512-lf/U8LLCLA8v2tAh2x4guizfFAZSt/KJSzzaIEXtYGospfeZVf2U0RfHlCo7+XvbUoAG4V3uyMgif/tjHQIYfA==", + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "bindings": "^1.3.1", + "nan": "^2.19.0" + }, + "engines": { + "node": ">=16" + } + }, "node_modules/npm-run-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-6.0.0.tgz", diff --git a/fastify2/package.json b/fastify2/package.json index 3c56048..f5b89fc 100644 --- a/fastify2/package.json +++ b/fastify2/package.json @@ -4,6 +4,7 @@ "dependencies": { "@platformatic/node": "^2.26.1", "fastify": "^5.1.0", - "undici": "^6.20.1" + "undici": "^6.20.1", + "node-rdkafka": "3.2.1" } } diff --git a/fastify2/server.js b/fastify2/server.js index 758e623..fc5ac90 100644 --- a/fastify2/server.js +++ b/fastify2/server.js @@ -1,5 +1,6 @@ import fastify from "fastify"; import { fetch } from "undici"; +import Kafka from "node-rdkafka"; const app = fastify(); @@ -15,6 +16,23 @@ app.get("/check", async () => { }); app.listen({ port: 3000 }, (err) => { + console.log("started with v.", Kafka.librdkafkaVersion); + + const consumer = new Kafka.KafkaConsumer( + { + "group.id": "kafka", + "metadata.broker.list": "localhost:9091", + }, + {} + ); + // consumer.addListener("foo", () => console.log("bar")); + consumer.connect(); + consumer.consume(); + // consumer.on("ready", () => { + // console.log("ready"); + // }); + console.log("consumer started"); + if (err) { app.log.error(err); process.exit(1);