Fix Composer Process Timeout Issues

Recently I started contributing to an Open Source WordPress plugin and unfortunately I kept hitting a wall with the process timeout caused when installing Composer dependencies.

After some research, I found several ways to by-pass this timeout, one of which was decided to implement in the package.


Recommended

The recommended way of disabling the Composer timeout is on each script execution, using the builtin method provided by Composer: Composer\Config::disableProcessTimeout. Doing so keeps the timeout setting specific to tasks and does not pass this setting to other scripts or processes.

scripts: {
  "pre-install-cmd": [
    "Composer\Config::disableProcessTimeout"
  ]
}

Other Methods

The following is a set of other methods which also disable the timeout, but can be destructive when the timeout serves a distinct purpose.

Set Globally

The quickest (and probably most distructive) way to disable the timeout is by setting the var on your system.

export COMPOSER_PROCESS_TIMEOUT=600

Set for a Package

Optionally you can set the timeout within the package config:

config: {
  "process-timeout": 600
}

Set for a Command

Another way would be to set the timeout for each individual command.

COMPOSER_PROCESS_TIMEOUT=600; composer install

The first two are still a bit overbearing, while the third would only apply to that specific command, and that can be useful in many circumstances.

Personally, I use the recommended method or the per-command method when I need a quick process timeout removal.


·