acorn-prettify icon indicating copy to clipboard operation
acorn-prettify copied to clipboard

NiceSearchModule: aborting with incomplete response

Open RafaelKr opened this issue 1 year ago • 0 comments

Version

1.0.2

What did you expect to happen?

Searching with nice-search enabled should redirect me to the correct path.

What actually happens?

My FastCGI based webserver returned a response with the correct Location header, but status code 200. This leads to a blank page instead of the expected redirect.

I'm using caddy and the logs showed: aborting with incomplete response

Steps to reproduce

  1. Use caddy with the php_fastcgi directive with the following (simplified) configuration:
{
  # Prevents binding to port 80 which would need root privileges
	auto_https disable_redirects
}

https://example.localhost:8443 {
  handle /bud/* {
    reverse_proxy http://localhost:4000
  }

  root * public

  encode zstd gzip

  php_fastcgi "unix//run/php/php8.2-fpm.sock"

  file_server
}

Also every other reverse proxy with fastcgi should work.

  1. Do a search

Workaround

I can fix it by going to https://github.com/roots/acorn-prettify/blob/1d417f8b4dfbf93e82148d7e9a35e5b3cde5cf53/src/Modules/NiceSearchModule.php#L56 and replace the exit; with

if (function_exists('fastcgi_finish_request')) {
    fastcgi_finish_request();
} else {
    exit;
}

This is how Symfony is handling this (also Laravel uses the same Symfony component): https://github.com/symfony/symfony/blob/5938c51403b567fca54ef758071f54622475f141/src/Symfony/Component/HttpFoundation/Response.php#L392

And this is the WordPress wp_die() function: https://github.com/WordPress/wordpress-develop/blob/dfd1de09afbb5b3c4c7a959b20a1f5fa7011aa46/src/wp-includes/functions.php#L3717

System info

Linux Mint 21.3 with https://devenv.sh/ which is based on the nix package manager.

Log output

No response

Please confirm this isn't a support request.

Yes

RafaelKr avatar Jul 30 '24 21:07 RafaelKr