Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keeps on getting hung up with no message #7988

Closed
7thstorm opened this issue Jun 13, 2023 · 6 comments
Closed

Keeps on getting hung up with no message #7988

7thstorm opened this issue Jun 13, 2023 · 6 comments
Labels

Comments

@7thstorm
Copy link

Rector version: 0.17.0
OS windows 11 Pro

commands:
vendor\bin\rector process path-to-folder --debug --dry-run
also:
vendor\bin\rector process path-to-folder --debug --dry-run >> output.txt

Rector.php contents:

<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig->paths([
        __DIR__ . '/files',
    ]);

    // Skip certain paths
    
    // configure parallel processing
    $rectorConfig->parallel(
        $seconds = 600,
        $maxNumberOfProcess = 10,
        $jobSize = 16
    );

    // register a single rule
    $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);

    // define sets of rules
    $rectorConfig->sets([
        LevelSetList::UP_TO_PHP_82
    ]);
};

It does not appear to be stuck at any one file. Whether I output to a text file on console, it gets stuck.
I have a fairly powerful system i9 24 cores 64gb ram
there are about 14,000 php files

There is no error message

@7thstorm 7thstorm added the bug label Jun 13, 2023
@samsonasik
Copy link
Member

Please try latest dev-main:

composer config minimum-stability dev
composer config prefer-stable true
composer require --dev rector/rector:dev-main

If the issue persist, please provide reproducible test on https://getrector.com/demo/ , or we need simple reproducible code for that that show error, with only 1 or 2 rules, you can provide reproducible github repo, better with github action running

https://tomasvotruba.com/blog/2021/02/01/effective-debug-tricks-narrow-scoping/

@7thstorm
Copy link
Author

7thstorm commented Jun 13, 2023

OK, so I did what you ask, and used the latest dev-main. But the results were the same. It kept on stalling on certain files each time I ran.

Those particular files it was stalling on ran through fine on the demo page, using the same rector.php settings so they did not appear to the cause of the stalls.

so, next, I tried to narrow the scope and scanned even a narrower set of files. This folder included files it got hung up on before.

This time, using a narrower scope, it completed the scan and wrote this error at the end:
(note filenames and paths are sanitized)

[ERROR] Could not process "x:\file\path\file-path\filepath\some-file-name.php" file, due to: 
   
         "System error: "Call to a member function getAttribute() on null"
     ```

Stack trace:

    ```

#0
phar://x:/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/N
odeScopeResolver.php(1851): PHPStan\Analyser\NodeScopeResolver->processArgs()
#1
phar://x:/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/N
odeScopeResolver.php(575): PHPStan\Analyser\NodeScopeResolver->processExprNode()
#2
phar://x:/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/N
odeScopeResolver.php(338): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#3
x:\vendor\rector\rector\packages\NodeTypeResolver\PHPStan\Scope\PHPStanNodeScopeR
esolver.php(352): PHPStan\Analyser\NodeScopeResolver->processNodes()
#4
x:\vendor\rector\rector\packages\NodeTypeResolver\PHPStan\Scope\PHPStanNodeScopeR
esolver.php(235):
Rector\NodeTypeResolver\PHPStan\Scope\PHPStanNodeScopeResolver->processNodesWithDependentFiles()
#5 x:\vendor\rector\rector\src\Application\ChangedNodeScopeRefresher.php(93):
Rector\NodeTypeResolver\PHPStan\Scope\PHPStanNodeScopeResolver->processNodes()
#6 x:\vendor\rector\rector\src\Rector\AbstractRector.php(367):
Rector\Core\Application\ChangedNodeScopeRefresher->refresh()
#7 x:\vendor\rector\rector\src\Rector\AbstractRector.php(351):
Rector\Core\Rector\AbstractRector->refreshScopeNodes()
#8 x:\vendor\rector\rector\src\Rector\AbstractRector.php(242):
Rector\Core\Rector\AbstractRector->postRefactorProcess()
#9
x:\vendor\rector\rector\vendor\nikic\php-parser\lib\PhpParser\NodeTraverser.php(1
13): Rector\Core\Rector\AbstractRector->enterNode()
#10
x:\vendor\rector\rector\vendor\nikic\php-parser\lib\PhpParser\NodeTraverser.php(1
96): PhpParser\NodeTraverser->traverseNode()
#11
x:\vendor\rector\rector\vendor\nikic\php-parser\lib\PhpParser\NodeTraverser.php(1
05): PhpParser\NodeTraverser->traverseArray()
#12
x:\vendor\rector\rector\vendor\nikic\php-parser\lib\PhpParser\NodeTraverser.php(1
96): PhpParser\NodeTraverser->traverseNode()
#13
x:\vendor\rector\rector\vendor\nikic\php-parser\lib\PhpParser\NodeTraverser.php(1
05): PhpParser\NodeTraverser->traverseArray()
#14
x:\vendor\rector\rector\vendor\nikic\php-parser\lib\PhpParser\NodeTraverser.php(1
96): PhpParser\NodeTraverser->traverseNode()
#15
x:\vendor\rector\rector\vendor\nikic\php-parser\lib\PhpParser\NodeTraverser.php(1
05): PhpParser\NodeTraverser->traverseArray()
#16
x:\vendor\rector\rector\vendor\nikic\php-parser\lib\PhpParser\NodeTraverser.php(1
96): PhpParser\NodeTraverser->traverseNode()
#17
x:\vendor\rector\rector\vendor\nikic\php-parser\lib\PhpParser\NodeTraverser.php(1
05): PhpParser\NodeTraverser->traverseArray()
#18
x:\vendor\rector\rector\vendor\nikic\php-parser\lib\PhpParser\NodeTraverser.php(1
96): PhpParser\NodeTraverser->traverseNode()
#19
x:\vendor\rector\rector\vendor\nikic\php-parser\lib\PhpParser\NodeTraverser.php(8
5): PhpParser\NodeTraverser->traverseArray()
#20
x:\vendor\rector\rector\src\PhpParser\NodeTraverser\RectorNodeTraverser.php(43):
PhpParser\NodeTraverser->traverse()
#21 x:\vendor\rector\rector\src\Application\FileProcessor.php(52):
Rector\Core\PhpParser\NodeTraverser\RectorNodeTraverser->traverse()
#22
x:\vendor\rector\rector\src\Application\FileProcessor\PhpFileProcessor.php(115):
Rector\Core\Application\FileProcessor->refactor()
#23 x:\vendor\rector\rector\packages\Parallel\WorkerRunner.php(136):
Rector\Core\Application\FileProcessor\PhpFileProcessor->process()
#24 x:\vendor\rector\rector\packages\Parallel\WorkerRunner.php(107):
Rector\Parallel\WorkerRunner->processFile()
#25
x:\vendor\rector\rector\vendor\evenement\evenement\src\Evenement\EventEmitterTrai
t.php(97): Rector\Parallel\WorkerRunner->Rector\Parallel{closure}()
#26 x:\vendor\rector\rector\vendor\clue\ndjson-react\src\Decoder.php(117):
RectorPrefix202306\Evenement\EventEmitter->emit()
#27
x:\vendor\rector\rector\vendor\evenement\evenement\src\Evenement\EventEmitterTrai
t.php(97): RectorPrefix202306\Clue\React\NDJson\Decoder->handleData()
#28 x:\vendor\rector\rector\vendor\react\stream\src\Util.php(62):
RectorPrefix202306\Evenement\EventEmitter->emit()
#29
x:\vendor\rector\rector\vendor\evenement\evenement\src\Evenement\EventEmitterTrai
t.php(97): RectorPrefix202306\React\Stream\Util::RectorPrefix202306\React\Stream{closure}()
#30
x:\vendor\rector\rector\vendor\react\stream\src\DuplexResourceStream.php(154):
RectorPrefix202306\Evenement\EventEmitter->emit()
#31
x:\vendor\rector\rector\vendor\react\event-loop\src\StreamSelectLoop.php(201):
RectorPrefix202306\React\Stream\DuplexResourceStream->handleData()
#32
x:\vendor\rector\rector\vendor\react\event-loop\src\StreamSelectLoop.php(173):
RectorPrefix202306\React\EventLoop\StreamSelectLoop->waitForStreamActivity()
#33 x:\vendor\rector\rector\src\Console\Command\WorkerCommand.php(63):
RectorPrefix202306\React\EventLoop\StreamSelectLoop->run()
#34 x:\vendor\rector\rector\vendor\symfony\console\Command\Command.php(325):
Rector\Core\Console\Command\WorkerCommand->execute()
#35 x:\vendor\rector\rector\vendor\symfony\console\Application.php(944):
RectorPrefix202306\Symfony\Component\Console\Command\Command->run()
#36 x:\vendor\rector\rector\vendor\symfony\console\Application.php(326):
RectorPrefix202306\Symfony\Component\Console\Application->doRunCommand()
#37 x:\vendor\rector\rector\src\Console\ConsoleApplication.php(49):
RectorPrefix202306\Symfony\Component\Console\Application->doRun()
#38 x:\vendor\rector\rector\vendor\symfony\console\Application.php(212):
Rector\Core\Console\ConsoleApplication->doRun()
#39 x:\vendor\rector\rector\bin\rector.php(132):
RectorPrefix202306\Symfony\Component\Console\Application->run()
#40 x:\vendor\rector\rector\bin\rector(5): require_once('...')
#41 x:\vendor\bin\rector(119): include('...')
#42 {main}". On line: 2828

         

@samsonasik
Copy link
Member

we unfortunatelly can't help without reproducible code and rule(s) that cause a bug.

@7thstorm
Copy link
Author

Is there a hard limit on how many files that be run in one go? Because it seems to be completed most of the time when I run on a smaller subset (most of the time)

@7thstorm
Copy link
Author

7thstorm commented Jun 26, 2023

we unfortunately can't help without reproducible code and rule(s) that cause a bug.

I tried to reproduce it on your demo site. I trimmed the file to meet the 100 line requirement and ran the 4 MySQL individual rules.

While I did not get errors, there were no file changes either. My expectation was this file should have been changed. Or is my understanding not right?

here is the link to the demo: https://getrector.com/demo/03796e2f-4c74-4ce4-9f16-a8987b2ba578

My command line is:
php vendor\bin\rector process folder\subfolder\filename.php -vvv --clear-cache --debug --output-format=json > rector_output.txt

My rector.php file is:

<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {

    // register a single rule
    $rectorConfig->rule(\Rector\MysqlToMysqli\Rector\Assign\MysqlAssignToMysqliRector::class);
    $rectorConfig->rule(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlFuncCallToMysqliRector::class);
    $rectorConfig->rule(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlPConnectToMysqliConnectRector::class);
   $rectorConfig->rule(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlQueryMysqlErrorWithLinkRector::class);


};

the end result is always the same:

{
    "totals": {
        "changed_files": 0,
        "errors": 0
    }
}

@samsonasik
Copy link
Member

Closing as it seems resolved at rectorphp/rector-src#4375

Please create separate issue with specific rule and specific expected output when you found an issue to keep focus to fix issue one by one.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants