Skip to content

Do not abort the whole install when importmap:require fails - #1097

Open
Amoifr wants to merge 1 commit into
symfony:2.xfrom
Amoifr:fix-1015-importmap-fail-safe
Open

Do not abort the whole install when importmap:require fails#1097
Amoifr wants to merge 1 commit into
symfony:2.xfrom
Amoifr:fix-1015-importmap-fail-safe

Conversation

@Amoifr

@Amoifr Amoifr commented Jul 22, 2026

Copy link
Copy Markdown

Fixes #1015.

When PackageJsonSynchronizer synchronizes AssetMapper packages, it runs importmap:require, which reaches out to the network (the jsDelivr API). If that call fails (a rate limit, or just bad connectivity, as @nicolas-grekas hit during a workshop), the ScriptExecutionException propagates and aborts the whole composer require, leaving the app half configured with no obvious way for a newcomer to recover.

This makes that step fail safe: a failing importmap:require no longer aborts the install. The entries that could not be added are collected and reported at the end, with a hint to run composer install again once the network is back (the synchronization re-runs on every install and retries the missing entries).

Before:

Executing script importmap:require [KO]
 [KO]
Script importmap:require returned with error code 1
[the whole "composer require webapp" aborts]

After the recipes are still applied, and you get:

Could not add the following packages to your importmap: @hotwired/stimulus.
This is often caused by a temporary network issue. Run "composer install" again once your connection is back to add them.

This is the smaller, incremental fix. @nicolas-grekas, you mentioned you'd rather have PackageJsonSynchronizer not touch the network at all and defer it to a later stage (e.g. cache:clear). That is a larger change, happy to look into it separately if you'd prefer that direction instead.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PackageJsonSynchronizer is not fail safe

1 participant