# Webhook race condition mitigation strategies

**URL:** https://meta.discourse.org/t/webhook-race-condition-mitigation-strategies/385090
**Category:** Development
**Created:** [October 8, 2025, 9:22pm UTC](https://meta.discourse.org/t/webhook-race-condition-mitigation-strategies/385090 "2025-10-08T21:22:31Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![devaoc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/devaoc/32/524119_2.png) [@devaoc](https://meta.discourse.org/u/devaoc)
#### Post date: [October 8, 2025, 9:22pm UTC](https://meta.discourse.org/t/webhook-race-condition-mitigation-strategies/385090/1 "2025-10-08T21:22:31Z")

</div>

Hey everyone! 👋

I’m working on building a two-way sync between **Discourse** and **Discord**. On the Discourse side, I’m using webhooks for topic and post events (created, edited, destroyed, recovered) to relay updates to the corresponding Discord channels. The other direction is handled using a bot built with `discord.js`.

I’ve been running into some issues getting my middleware to handle things cleanly — mainly due to a **race condition** between when topic and post webhooks are received.

I’d love some advice on how to best handle this. Right now, I’m considering dropping topic webhooks entirely and basing everything around post events (using `topic_id` as the unifier). That said, I’d prefer to find a way to make my current setup work rather than rewriting everything from scratch.

Any insights or suggestions would be greatly appreciated! 🙏

---

_[View the full topic](https://meta.discourse.org/t/webhook-race-condition-mitigation-strategies/385090)._
