Hook "woocommerce cancel unpaid orders" randomly not rescheduling after running?

Hi all, we are having this issue in this woocommerce store where the woocommerce_cancel_unpaid_orders cron is not rescheduling again properly. I checked php, nginx, even the syslog and nothing seems to be out of ordinary around the time this happens (we have some visitor spikes that tends to slow down a bit every now and then but usually not around the time this problem happens). We also have some “max children limit reached consider raising it” but not anywhere near the time this thing happens.

We are really having trouble to pinpoint the cause since it happened even when the store was down under “maintenance mode” and simply the cron does not reschedule again randomly it seems.

We tried using alternate cron no success and we have disable_wp_cron and are running linux cron every 5mins, so far everything else seems to be running ok, but the woocommerce_cancel_unpaid_orders not.

I am guessing this could be some sort of caching problems because a way to force the woocommerce_cancel_unpaid_orders to be scheduled is to go in Woocommerce config and changing the Hold stock for x minutes field, but often times I need to “purge cache” from admin bar or even going to prompt and doing a ee clean --all and then change the config in woocommerce again for it to appear in the cron list. Sometimes it runs fine for days, sometimes it happens more than once a day.

We are running EE v3.7.5 with php7.0 --w3tc (but really everything in it is disabled trying to figure it out) and fastcgi. Woocommerce 3.4.6 and WP 4.9.10.

We made this custom .conf to sort somethings out and even tried to squeeze in the specific php file that runs the function to see if it works, but still persists…

This is the content of the custom .conf:

if ( $cookie_woocommerce_items_in_cart = "1" ){
   set $skip_cache 1;
}

# Don't cache uris containing the following segments
if ($request_uri ~* "(/wishlist/|wc-order-functions.php|/finalizar-compra*|/minha-conta*|/carrinho*|/basket.*|/cart.*|/my-account.*|/checkout.*|/addons.*|/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
   set $skip_cache 1;
}

# FASTCGI Cache issues instructions from EE oficial site
location ~ \.php$ {
        set $rt_session "";

        if ($http_cookie ~* "wc_session_cookie_[^=]*=([^%]+)%7C") {
                set $rt_session wc_session_cookie_$1;
        }

        if ($skip_cache = 0 ) {
                more_clear_headers "Set-Cookie*";
                set $rt_session "";
        }

        fastcgi_cache_key "$scheme$request_method$host$request_uri$rt_session";

        try_files $uri =404;
}

If anybody else experienced this sort of problem and could help me out, much appreciated.

Hey, Fabio. Have you fixed this issue? I’m experiencing something similar :frowning:

1 Like

In our case we updated everything in WP and Woocommerce, it was curl timeout most probably. Make sure you are using server cron instead of WP’s and use WP-CLI so it runs no matter what. We added this line to cron tab replacing the curl one, this basicaly asks every minute WP-CLI to run all cronjobs that are due to run:

* * * * * cd /var/www/yourdomain.com/htdocs; wp cron event run --due-now --allow-root > /dev/null 2>&1

Bear in mind this was no 100% fix, since we got the hook vanishing again once, but it’s been a month now and I check daily to make sure it is there and it is. But to be fair we got this problem (like once a year more or less) even in non EasyEngine servers, so could be just a random glitch.

1 Like

Awesome! Thank you so much, Fabio!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.