phpinsights icon indicating copy to clipboard operation
phpinsights copied to clipboard

Able to set timeout limit

Open lloricode opened this issue 2 years ago • 1 comments

Q A
Bug report? no
Feature request? yes
Library version 2.0.1

Hi can we able to set this dynamically by adding ->setTimeout() ?

https://github.com/nunomaduro/phpinsights/blob/d07b45bb8add1f608fd007efbb989ecca59e3e96/src/Domain/Insights/SyntaxCheck.php#L54

I have an issue of timeout after adding more feature on a large project

php artisan insight --fix

 827/830 [â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–‘]  99%

   Symfony\Component\Process\Exception\ProcessTimedOutException 

  The process "/usr/bin/php7.4 '/home/vagrant/code/laravel/project-x/vendor/bin/parallel-lint' --no-colors --no-progress --json --exclude 'bower_components' --exclude 'node_modules' --exclude 'vendor' --exclude 'vendor-bin' --exclude '.phpstorm.meta.php' --exclude 'config' --exclude 'storage' --exclude 'resources' --exclude 'bootstrap' --exclude 'nova' --exclude 'database' --exclude 'server.php' --exclude '_ide_helper.php' --exclude '_ide_helper_models.php' --exclude 'app/Providers/TelescopeServiceProvider.php' --exclude 'public' --exclude 'swagger' --exclude 'routes/console.php' --exclude 'deprecated.php' --exclude 'vendor' --exclude 'tests' --exclude 'Tests' --exclude 'test' --exclude 'Test' ." exceeded the timeout of 60 seconds.

  at vendor/symfony/process/Process.php:1217
    1213â–• 
    1214â–•         if (null !== $this->timeout && $this->timeout < microtime(true) - $this->starttime) {
    1215â–•             $this->stop(0);
    1216â–• 
  ➜ 1217▕             throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_GENERAL);
    1218â–•         }
    1219â–• 
    1220â–•         if (null !== $this->idleTimeout && $this->idleTimeout < microtime(true) - $this->lastOutputTime) {
    1221â–•             $this->stop(0);

      +7 vendor frames 
  8   [internal]:0
      NunoMaduro\PhpInsights\Domain\Insights\InsightCollectionFactory::NunoMaduro\PhpInsights\Domain\Insights\{closure}()

      +17 vendor frames 
  26  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()
Script @php artisan insight --fix handling the insight-fix event returned with error code 1

in my case trying this will working

        $process
            ->setTimeout(60*5)
            ->run();

Thank you

lloricode avatar Oct 22 '21 02:10 lloricode

This would make a good PR, adding in an option to set timeouts would be cool.

JustSteveKing avatar Mar 08 '22 12:03 JustSteveKing