Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG] rendering fails on large request body #139

Open
eWert-Online opened this issue Jun 3, 2024 · 0 comments · May be fixed by #140
Open

[BUG] rendering fails on large request body #139

eWert-Online opened this issue Jun 3, 2024 · 0 comments · May be fixed by #140

Comments

@eWert-Online
Copy link

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).

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant