Thanks for the report. This can happen on sites which perform an exceptionally high number of database queries, trigger a high number of PHP errors, or otherwise use a large percentage of the available memory limit on your server. Sometimes the amount of data that has to QM collect will cause it to go over the memory limit or cause other problems.
In this case, the request to the server often succeeds but the response won’t make it back to your browser, either due to memory exhaustion or, if you’re using an Nginx proxy, response size limits.
I don’t have much advice other than to try addressing any PHP errors that Query Monitor reports (or that you see in your PHP error log) and to try switching your theme to one of the default “Twenty” themes to see if that helps. Basically, try to reduce the amount of data that QM has to collect and display back to you.
I understand this is ironic given that QM is intended to help in this situation, but there’s nothing it can do about memory limits or server resource restrictions.
I just did a fresh install with a new nginx server running PHP 8.2 and ran into this with admin-ajax.php 502 errors and tried even a ‘WP_MEMORY_LIMIT’ of ‘1024M’
I noticed it when trying to save/update WooCommerce orders and saving Gravity Forms.
I did not come across these errors with PHP 7.4.
Disabling QM fixed the issue.
I’m getting the same error on WPEngine. It was working on PHP7.4, but when I switch to PHP8.2, I get 502 errors in lots of places, mostly in admin-ajax.php. WP is up to date at v6.3.
Saving a post/page is the simplest one. The actual post is saved, though, so the error takes place somewhere after that.
The problem is that this happens for non-admin users as well on other sections of the site, not always tied to Ajax requests. My solution will be to disable the plugin for now.
I don’t think the memory is the problem, I have memory limit set to 1024 (or 512), so it should be plenty. The 502 happens with all other plugins disabled as well when I save a page, so I don’t think that action can overload the memory.
Hopefully this is something that you can figure out in later versions.
Thanks!
-
This reply was modified 2 years, 9 months ago by
eugenlisov.
I ran into this same problem with HTTP 502 errors on WP-Engine. I am observing that there are a lot of deprecation notices coming from certain plugins when running PHP 8.2. On AJAX requests, QM injects all of the PHP errors/warnings/notices/deprecations into the HTTP headers, including full stack traces. It appears that at a certain cutoff, the size of the headers become too big, causing WP-Engine to throw the 502 error. I haven’t nailed down exactly what the cutoff is, it seems to be higher than 32KB and less than 80KB.
Two possible workarounds I have found are:
- Disable PHP output in headers:
function disable_qm_php_header( $output ) {
unset($output['php_errors']);
return $output;
}
add_filter( 'qm/outputter/headers', 'disable_qm_php_header', 999, 1 );
2. Suppress notices and deprecations for the problem plugin (In my case, it was the cleantalk plugin):
add_filter( 'qm/collect/php_error_levels', function( array $levels ) {
$levels['plugin']['cleantalk-spam-protect'] = ( E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED );
return $levels;
} );
@johnbillion – It might make sense for QM to self-impose a limit on how many bytes of headers it will try to output.
The problem with self-imposed limits is how to determine the size of the limit. There’s some discussion on this GitHub issue: https://github.com/johnbillion/query-monitor/issues/708 , mostly focused on errors in Ajax responses.
Ultimately I’m going to move away from outputting the data from Query Monitor inline so the problem gets eliminated, no ETA on that just yet though.