From 59f5770e1e773c4c9fea6101cf97c73623c83ff6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikko=20Pyykk=C3=B6?= Date: Mon, 13 Mar 2023 18:07:18 +0200 Subject: [PATCH] fix kafkaBridge headers sent error --- backend/bin/kafkaBridge.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/bin/kafkaBridge.ts b/backend/bin/kafkaBridge.ts index 51c949585..675e2687b 100644 --- a/backend/bin/kafkaBridge.ts +++ b/backend/bin/kafkaBridge.ts @@ -83,16 +83,16 @@ app.post("/kafka-bridge/api/v0/event", async (req, res) => { try { producer.produce(topic, null, Buffer.from(JSON.stringify(payload))) - flushProducer(1000).catch((err) => { - logger.warn(new KafkaError("Flushing the producer failed", err)) - return res.status(500).json({ error: err.toString() }).send() - }) + return flushProducer(1000) + .then(() => res.json({ msg: "Thanks!" }).send()) + .catch((err) => { + logger.warn(new KafkaError("Flushing the producer failed", err)) + return res.status(500).json({ error: err.toString() }).send() + }) } catch (e: any) { logger.error(new KafkaError("Producing to kafka failed", e)) return res.status(500).json({ error: e.toString() }).send() } - - return res.json({ msg: "Thanks!" }).send() }) app.get("/kafka-bridge/api/v0/healthz", (_, res) => {