0

I'm facing an issue when trying to install the FilePond library using Symfony's importmap system.

I attempted to add FilePond to my project by running php bin/console importmap:require filepond (or by manually adding an entry in my importmap.php file), followed by php bin/console importmap:install. However, as soon as I run the install command, I get the following error:

In ErrorChunk.php line 73:
  Body size limit exceeded

In Http2ConnectionProcessor.php line 711:
  Body size limit exceeded

In Http2ConnectionProcessor.php line 757:
  Body size limit exceeded

I have tried several solutions to fix this issue:

Increasing the HTTP client's body size limit by modifying the php.ini file (adjusting memory_limit, upload_max_filesize, etc.), and redefining the HTTP client service in services.yaml with the max_body_size option.

Changing the FilePond entry to use a "path" with a direct CDN URL instead of "version", to bypass automatic resolution.

Despite these attempts, the error persists, and I can't properly download the assets from the CDN.

Has anyone encountered this issue with FilePond or other libraries via importmap? Any suggestions on how to bypass this size limit?

Thanks in advance for your help!

2 Answers 2

0

The Body size limit exceeded error when running php bin/console importmap:install in Symfony typically occurs because Symfony’s HTTP client enforces a default 10MB response body limit. This limit affects the Importmap system when downloading large JavaScript packages like FilePond.

There are two possible solutions: configure this limit and using CDN

Configure limit

Symfony allows customization of the HTTP client used by the Importmap system. You can override the client and remove the body size restriction safely.

1. In your config/services.yaml, add the following:

services:
    Symfony\Component\AssetMapper\ImportMap\HttpClient\PackageDownloader:
        arguments:
            $client: '@importmap.http_client'

    importmap.http_client:
        class: Symfony\Contracts\HttpClient\HttpClientInterface
        factory: ['Symfony\Component\HttpClient\HttpClient', 'create']
        arguments:
            -
                max_body_length: 0 # 0 means no limit

2. Then clear the cache and reinstall the packages:

php bin/console cache:clear
php bin/console importmap:install

Setting max_body_length: 0 disables the body size limit only for the Importmap-related HTTP client, not for the rest of your application (unless you’ve globally overridden the default HTTP client).

CDN

If you’d rather load FilePond directly from a CDN without downloading it locally, you can run:

php bin/console importmap:require filepond --path=https://unpkg.com/filepond@^4/dist/filepond.js

This will register the script in your importmap.php, but it will not download it to your local project — it will be loaded from the CDN at runtime.

Sign up to request clarification or add additional context in comments.

1 Comment

Hi Michael Sivolobov, Thanks for your suggestions. I tried both approaches, but I still encountered issues: With the first solution, I got this error: Invalid service "Symfony\Component\AssetMapper\ImportMap\HttpClient\PackageDownloader": class "Symfony\Component\AssetMapper\ImportMap\HttpClient\PackageDownloader" does not exist. I’m aiming to integrate FilePond locally (i.e., without relying on a CDN). Could it be that I’ve missed a configuration step or perhaps used the wrong namespace? Any pointers on what might be wrong with my setup ? Thanks in advance for your help.
0

I found the solution after thoroughly checking Symfony's issues!

The issue was caused by an outdated HTTP client. To fix it, simply update the HTTP client by running:

composer require amphp/http-client

After installing this package, the importmap:install command worked without any issues.

If anyone else encounters the "Body size limit exceeded" error, make sure your HTTP client is up to date. Hope this helps!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.