# Race condition between incoming webhook and existence of a page

**URL:** <https://forum.getkirby.com/t/race-condition-between-incoming-webhook-and-existence-of-a-page/35091>\
**Category:** Webdev\
**Created:** [December 14, 2025, 9:00am UTC](https://forum.getkirby.com/t/race-condition-between-incoming-webhook-and-existence-of-a-page/35091 "2025-12-14T09:00:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexpi](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/alexpi/32/12008_2.png) [@alexpi](https://forum.getkirby.com/u/alexpi)\
**Post date:** [December 14, 2025, 9:00am UTC](https://forum.getkirby.com/t/race-condition-between-incoming-webhook-and-existence-of-a-page/35091/1 "2025-12-14T09:00:45Z")

</div>

I am trying to implement a payment method for Merx and I am having the following issue. There is a race condition between the time an incoming webhook arrives and Kirby saving a page. The webhook expects the page (a customer order in this case) to exist, and this is not always true. The service sending the webhook suggests placing the webhook payload in a queue, and retrying later. Any ideas on how to implement that?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 14, 2025, 10:16am UTC](https://forum.getkirby.com/t/race-condition-between-incoming-webhook-and-existence-of-a-page/35091/2 "2025-12-14T10:16:42Z")

</div>

There was a plugin for Kirby 3 and 4: [Queue | Kirby CMS Plugins](https://plugins.getkirby.com/bvdputte/queue). Maybe it also works with Kirby 5 or can be made compatible easily, or you can at least use that as a basis for your own implementation.

But the general idea would be to have a way to store jobs somewhere (as job files, in a database etc.), have a script that executes those jobs and handles errors (retry, send notifications if needed) and a cron job that executes the script at a given interval.

---

<div class="post-metadata">

**Author:** ![alexpi](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/alexpi/32/12008_2.png) [@alexpi](https://forum.getkirby.com/u/alexpi)\
**Post date:** [December 15, 2025, 6:46am UTC](https://forum.getkirby.com/t/race-condition-between-incoming-webhook-and-existence-of-a-page/35091/3 "2025-12-15T06:46:23Z")

</div>

Before trying the plugin (which seems great for this situation), I tried a quick and dirty solution: I made the webhook handler sleep for 3 seconds, and also send a response status of 400 in the case the page does not yet exist (this causes the webhook to retry in an hour). I don’t know if using sleep() with a magic number is acceptable, but it seems to work.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 15, 2025, 10:57am UTC](https://forum.getkirby.com/t/race-condition-between-incoming-webhook-and-existence-of-a-page/35091/4 "2025-12-15T10:57:17Z")

</div>

As a “cheap” solution, I’d also suggested that.
