[wp-trac] [WordPress Trac] #63547: wp_remote_post not respecting timeout & blocking params

WordPress Trac noreply at wordpress.org
Mon Jun 9 03:09:09 UTC 2025


#63547: wp_remote_post not respecting timeout & blocking params
--------------------------+--------------------------
 Reporter:  mihai200      |       Owner:  westonruter
     Type:  defect (bug)  |      Status:  accepted
 Priority:  normal        |   Milestone:
Component:  HTTP API      |     Version:  6.7.2
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:  performance
--------------------------+--------------------------

Comment (by westonruter):

 I tried creating a plugin that sets the `CURLOPT_NOSIGNAL` option (as
 referenced in [https://github.com/WordPress/Requests/issues/826
 Requests#826]) on cURL for requests to spawn WP Cron:

 {{{#!php
 <?php
 /**
  * Plugin Name: WP Cron Perf Fix
  */

 namespace WPCronPerfFix;

 use CurlHandle;

 /**
  * Sets NOSIGNAL option on requests to spawn WP Cron.
  *
  * @param CurlHandle|resource $handle      The cURL handle returned by
 curl_init() (passed by reference).
  * @param array               $parsed_args The HTTP request arguments.
  * @param string              $url         The request URL.
  */
 function add_nosignal_opt( $handle, array $parsed_args, string $url ) {
         $parsed_url = wp_parse_url( $url );
         if (
                 isset( $parsed_url['host'], $parsed_url['path'],
 $parsed_args['blocking'] ) &&
                 wp_parse_url( site_url(), PHP_URL_HOST ) ===
 $parsed_url['host'] &&
                 'wp-cron.php' === basename( $parsed_url['path'] ) &&
                 ! $parsed_args['blocking']
         ) {
                 curl_setopt( $handle, CURLOPT_NOSIGNAL, 1 );
         }
 }

 add_action( 'http_api_curl', __NAMESPACE__ . '\add_nosignal_opt',  10, 3
 );
 }}}

 However, it is not improving the response time.

 To test, I've activated that plugin and I use WP-CLI to schedule a task
 and then immediately time the request the frontend:

 {{{
 npm run env:cli cron event schedule foo$(date +%s.%N) && time curl
 http://localhost:8889/ > /dev/null
 }}}

 The result is `0m1.177s`.

 When I try making a request without the cron scheduling, the transpired
 time is `0m0.150s`.

 **So spawning WP Cron is still adding an entire second to the response.**

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/63547#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list