WooCommerce webhooks are critical for syncing store actions—like order.created or customer.updated—with external systems like CRM platforms, accounting software, or custom shipping endpoints. However, a major infrastructure bug can trigger a "Webhook Loop Disaster." In this scenario, a single checkout event causes WooCommerce to send the exact same webhook payload dozens or hundreds of times to the receiving server within a few minutes.
This behavior severely lags your server, exhausts execution threads, and can result in external APIs blocking your site's IP address for hitting rate limits. The root cause is a breakdown in the HTTP handshake protocol. When WooCommerce fires a webhook, it expects a clean 200 OK response from the receiving server within a strict timeframe (defaulting to 5 seconds). If your recipient server takes 6 seconds to process the data before sending the success code, WooCommerce assumes the delivery failed. It then logs a failure attempt and immediately queues a retry task. If your external script continues to respond slowly, the retries stack exponentially, creating a self-inflicted Distributed Denial of Service (DDoS) loop.
The Solution
To break the execution loop, you must increase the system communication timeout parameters or decouple the immediate data processing block.
-
Extend Webhook Timeout Limit: Add this code to your child theme's
functions.phpfile to increase the webhook response window from 5 seconds to 30 seconds:PHPadd_filter('woocommerce_webhook_deliver_timeout', 'extend_wc_webhook_timeout'); function extend_wc_webhook_timeout($timeout) { return 30; } -
Deactivate Failure Logging Retries: If an external server frequently logs sluggish response windows but processes data fine, force WooCommerce to drop aggressive retries by lowering the failure threshold:
PHPadd_filter('woocommerce_max_webhook_delivery_failures', 'limit_webhook_failures'); function limit_webhook_failures($failures) { return 2; // Disables the webhook after 2 consecutive timeout drops } -
Process Asynchronously: Reconfigure your receiving API destination script to immediately return a
200 OKstatus header upon receiving the payload, and then process the intensive data logic in the background using a cron job.
