Description
When a request with a large body payload is made, the rendering fails, because it exceeds the max_post_size limit of ReactPHP.
ReactPHP limits the max_post_size by default to 64K, as mentioned in their README (https://github.com/reactphp/http?tab=readme-ov-file#httpserver):
In particular, the post_max_size setting limits how much memory a single HTTP request is allowed to consume while buffering its request body. This needs to be limited because the server can process a large number of requests concurrently, so the server may potentially consume a large amount of memory otherwise. To support higher concurrency by default, this value is capped at 64K. If you assign a higher value, it will only allow 64K by default. If a request exceeds this limit, its request body will be ignored and it will be processed like a request with no request body at all.
To support larger requests, the following changes would have to be made in the server--async.php
:
$server = new HttpServer(
new React\Http\Middleware\StreamingRequestMiddleware(),
new React\Http\Middleware\LimitConcurrentRequestsMiddleware(100), // 100 concurrent buffering handlers
new React\Http\Middleware\RequestBodyBufferMiddleware(2 * 1024 * 1024), // 2 MiB per request
static function (ServerRequestInterface $request) use ($twigRenderer, &$counter): Response|Promise {
// ...
}
)
This would increase the default max_post_size to 2MiB and limit the number of concurrent requests to 100 (to not increase the memory footprint of the server by too much).