valet icon indicating copy to clipboard operation
valet copied to clipboard

Prevent 502 errors when using AJAX

Open mattkingshott opened this issue 3 years ago • 4 comments

When using the Laravel DebugBar with the capture_ajax flag set to true, developers may encounter 502 Bad Gateway errors. This is due to DebugBar's AJAX request monitoring exceeding the FastCGI buffer limit.

This PR increases the size of the buffer. While it is not guaranteed to fix the problem, the increased buffer size should solve the issue for most developers. Further discussion on this subject can be found in this issue on the DebugBar repo.

mattkingshott avatar Jul 29 '21 15:07 mattkingshott

Is it intentional that this only applies to unsecured sites? ie: only on sites for which valet secure has NOT been run?

The change you're proposing is in the config file used only for unsecured sites. If one wishes this to be applied to both secured and unsecured sites, note that both types of site stubs have an include fastcgi_params directive, meaning the proposed changes could be placed in that file instead.

Also, is the temp_file_write_size and busy_buffers part really needed? Forcing unneeded settings on every Valet user can lead to unexpected outcomes.

drbyte avatar Jul 29 '21 17:07 drbyte

Thanks for the comments @drbyte. It wasn't intentional no, so I've done the following...

I've moved the required parameters to fastcgi_params and removed the unnecessary ones.

mattkingshott avatar Jul 29 '21 17:07 mattkingshott

Wondering: How does doing this affect RAM demands on sites? eg: what are the new requirements for using Valet?

drbyte avatar Jul 29 '21 18:07 drbyte

I’ve not noticed any difference with it enabled, but maybe it’s usage would increase by up to 1 MB for a request (based on the 512 K buffer size). Just guessing, really have no idea.

mattkingshott avatar Jul 29 '21 18:07 mattkingshott

There are a lot of people in this thread either talking about this or emoji responding positively to the folks talking about it, so I'm going to consider it tested enough, and merge it. Thanks!

mattstauffer avatar Dec 02 '22 01:12 mattstauffer