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) => {