Skip to content

Commit 59f5770

Browse files
committed
fix kafkaBridge headers sent error
1 parent 8bdb5ad commit 59f5770

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

backend/bin/kafkaBridge.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,16 @@ app.post("/kafka-bridge/api/v0/event", async (req, res) => {
8383

8484
try {
8585
producer.produce(topic, null, Buffer.from(JSON.stringify(payload)))
86-
flushProducer(1000).catch((err) => {
87-
logger.warn(new KafkaError("Flushing the producer failed", err))
88-
return res.status(500).json({ error: err.toString() }).send()
89-
})
86+
return flushProducer(1000)
87+
.then(() => res.json({ msg: "Thanks!" }).send())
88+
.catch((err) => {
89+
logger.warn(new KafkaError("Flushing the producer failed", err))
90+
return res.status(500).json({ error: err.toString() }).send()
91+
})
9092
} catch (e: any) {
9193
logger.error(new KafkaError("Producing to kafka failed", e))
9294
return res.status(500).json({ error: e.toString() }).send()
9395
}
94-
95-
return res.json({ msg: "Thanks!" }).send()
9696
})
9797

9898
app.get("/kafka-bridge/api/v0/healthz", (_, res) => {

0 commit comments

Comments
 (0)