Skip to content

[AssetMapper] Unable to import package with a lot of extrafiles #62623

@mbuliard

Description

@mbuliard

Symfony version(s) affected

7.3, probably others

Description

Hello !

On our current project, we use symfony/asset-mapper 7.3.5, it works fine.

But we have to add the DSFR (french governement design system) icons : @gouvfr/dsfr/dist/utility/icons/icons.min.css : https://cdn.jsdelivr.net/npm/@gouvfr/dsfr@1.14.2/dist/utility/icons/icons.min.css
Unfortunately, it links thousands of icons files.

When trying to importmap:install the command throw an error:

Image

While by debugging, we found the issue to be in src/Symfony/Component/AssetMapper/ImportMap/Resolver/JsDelivrEsmResolver.php, line 210 :
$extraFileResponses[$package][] = [$this->httpClient->request('GET', \sprintf(self::URL_PATTERN_DIST_CSS, $entry->getPackageName(), $entry->version, $extraFile)), $extraFile, $entry->getPackageName(), $entry->version];
An asynchronous request is sent for each of the thousands of files, exceeding file limits.
When making the request synchronous (for example by waiting for the status code), the problem is fixed, but the request is longer.

How to reproduce

https://github.com/JJarrie/dsfr_icons_reproducer

Possible Solution

I think sending chunks of 1000 requests and waiting for them to be resolved would be a better solution

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions