DEV Community

Ibrar Hussain
Ibrar Hussain

Posted on

How to disable process timeout for Composer scripts

If you have composer.json file in your project, then you might have some custom script in the scripts section that you want to execute via composer {script-name} command.
For example, in your Laravel project you have phpunit and want to create a custom script for coverage test and your composer scripts section might look like this:

"scripts": {
...
    "coverage-test": [
        "./vendor/bin/phpunit --coverage-html tests/Reports"
    ]
}
Enter fullscreen mode Exit fullscreen mode

When executing this command:

composer coverage-test
Enter fullscreen mode Exit fullscreen mode

there is a possibility (depending on your test cases you have) that you might get the following error:

[Symfony\Component\Process\Exception\ProcessTimedOutException]                                 
The process "coverage-test --coverage-html tests/Reports" exceeded the timeout of 300 seconds.
Enter fullscreen mode Exit fullscreen mode

You can fix it by updating your script to like this:

"scripts": {
...
    "coverage-test": [
        "Composer\\Config::disableProcessTimeout",
        "./vendor/bin/phpunit --coverage-html tests/Reports"
    ]
}
Enter fullscreen mode Exit fullscreen mode

If your try the command composer coverage-test now, it should work without any errors.

References:

Discussion (0)