ProcessTimedOutException during package installation in Composer
0 reputation · 10 Mar 2020, 07:37 UTC
0 reputation · 10 Mar 2020, 07:37 UTC
Composer uses a process-timeout configuration to prevent hanging operations during package downloads or script executions. When a process exceeds this limit, the system triggers a ProcessTimedOutException to halt the operation.
While the timeout prevents orphaned processes on build servers, the behavior regarding the local cache directory remains unclear. Specifically, when a download is interrupted by this exception, the state of the partially downloaded archive in the cache is not explicitly defined.
Does Composer automatically purge incomplete archives from the cache after a ProcessTimedOutException occurs? If not, how does the manager handle these partial files during subsequent installation attempts?
34275 reputation · 10 Mar 2020, 16:12 UTC
No. When a ProcessTimedOutException aborts a download, Composer does not immediately remove the partially fetched archive from its cache. The file remains in the cache directory (typically $COMPOSER_HOME/cache/files or the repository‑specific cache) until the next Composer operation that needs that package.
Before using a cached dist file, Composer verifies its integrity by comparing the SHA‑256 hash recorded in packages.json (or the lock file) with the hash of the cached file. If the hash does not match – which is the case for an incomplete or corrupted download – Composer deletes the bad file and retries the download from the source.
Increase the process timeout if the error recurs:
export COMPOSER_PROCESS_TIMEOUT=600 # or composer config -g process-timeout 600
Run the installation again with verbose output to see whether the timeout persists:
composer install -vvv
If the timeout continues, check for common causes (slow network, large VCS clones, resource limits) and consider:
--prefer-dist to avoid heavy cloning.composer clear-cache.Confirm that PHP’s execution limit is not lower than the Composer timeout:
php -r "echo ini_get('max_execution_time');"
If you are still seeing ProcessTimedOutException after raising the timeout, please share the exact command that fails and whether the issue occurs with a specific package or across all dependencies; that detail would determine whether a deeper script or plugin investigation is needed.
Use comments to ask for clarification. Post a solution as an answer.
34,275 reputation · 10 Mar 2020, 09:13 UTC
One clarification worth making: process-timeout governs Composer script and plugin processes via Symfony Process, not the HTTP fetch itself. Package downloads use separate network timeouts, so a ProcessTimedOutException during install often originates from a post-install script rather than the archive download.
Regarding cache state, Composer generally writes package archives to a temporary file and moves them into the final cache path only after the download completes successfully. A timeout therefore usually leaves no partial archive in the reusable cache directory. Any leftover temporary artifacts are not validated against lock metadata on the next run; they are ignored and a fresh download occurs.
This behavior differs between Composer 1 and Composer 2 because download and cache internals were reworked. Verify against your installed major version with composer --version and inspect cache contents before and after a timeout.