Skip to content

Uncaught Error: Typed property RectorPrefix202512\Symplify\EasyParallel\ValueObject\ParallelProcess::$encoder must not be accessed before initialization #7

@devnix

Description

@devnix

Hi! I'm frequently getting the following stacktrace when running Rector on a big project, it happens sometimes on the first half of the process if there is no previous cache:

PHP Fatal error:  Uncaught Error: Typed property RectorPrefix202512\Symplify\EasyParallel\ValueObject\ParallelProcess::$encoder must not be accessed before initialization in [...]/vendor/rector/rector/vendor/symplify/easy-parallel/src/ValueObject/ParallelProcess.php:108
Stack trace:
#0 [...]/vendor/rector/rector/vendor/symplify/easy-parallel/src/ValueObject/ProcessPool.php(48): RectorPrefix202512\Symplify\EasyParallel\ValueObject\ParallelProcess->quit()
#1 [...]/vendor/rector/rector/vendor/symplify/easy-parallel/src/ValueObject/ProcessPool.php(58): RectorPrefix202512\Symplify\EasyParallel\ValueObject\ProcessPool->quitProcess()
#2 [...]/vendor/rector/rector/src/Parallel/Application/ParallelFileProcessor.php(107): RectorPrefix202512\Symplify\EasyParallel\ValueObject\ProcessPool->quitAll()
#3 [...]/vendor/rector/rector/vendor/symplify/easy-parallel/src/ValueObject/ParallelProcess.php(96): Rector\Parallel\Application\ParallelFileProcessor->Rector\Parallel\Application\{closure}()
#4 [...]/vendor/rector/rector/vendor/react/event-loop/src/Timer/Timers.php(86): RectorPrefix202512\Symplify\EasyParallel\ValueObject\ParallelProcess->RectorPrefix202512\Symplify\EasyParallel\ValueObject\{closure}()
#5 [...]/vendor/rector/rector/vendor/react/event-loop/src/StreamSelectLoop.php(150): RectorPrefix202512\React\EventLoop\Timer\Timers->tick()
#6 [...]/vendor/rector/rector/src/Parallel/Application/ParallelFileProcessor.php(185): RectorPrefix202512\React\EventLoop\StreamSelectLoop->run()
#7 [...]/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(234): Rector\Parallel\Application\ParallelFileProcessor->process()
#8 [...]/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(126): Rector\Application\ApplicationFileProcessor->runParallel()
#9 [...]/vendor/rector/rector/src/Console/Command/ProcessCommand.php(172): Rector\Application\ApplicationFileProcessor->run()
#10 [...]/vendor/rector/rector/vendor/symfony/console/Command/Command.php(289): Rector\Console\Command\ProcessCommand->execute()
#11 [...]/vendor/rector/rector/vendor/symfony/console/Application.php(892): RectorPrefix202512\Symfony\Component\Console\Command\Command->run()
#12 [...]/vendor/rector/rector/vendor/symfony/console/Application.php(279): RectorPrefix202512\Symfony\Component\Console\Application->doRunCommand()
#13 [...]/vendor/rector/rector/src/Console/ConsoleApplication.php(60): RectorPrefix202512\Symfony\Component\Console\Application->doRun()
#14 [...]/vendor/rector/rector/vendor/symfony/console/Application.php(162): Rector\Console\ConsoleApplication->doRun()
#15 [...]/vendor/rector/rector/bin/rector.php(130): RectorPrefix202512\Symfony\Component\Console\Application->run()
#16 [...]/vendor/rector/rector/bin/rector(5): require_once('...')
#17 [...]/vendor/bin/rector(119): include('...')
#18 {main}
  thrown in [...]/vendor/rector/rector/vendor/symplify/easy-parallel/src/ValueObject/ParallelProcess.php on line 108
Fatal error: Uncaught Error: Typed property RectorPrefix202512\Symplify\EasyParallel\ValueObject\ParallelProcess::$encoder must not be accessed before initialization in [...]/vendor/rector/rector/vendor/symplify/easy-parallel/src/ValueObject/ParallelProcess.php:108
Stack trace:
#0 [...]/vendor/rector/rector/vendor/symplify/easy-parallel/src/ValueObject/ProcessPool.php(48): RectorPrefix202512\Symplify\EasyParallel\ValueObject\ParallelProcess->quit()
#1 [...]/vendor/rector/rector/vendor/symplify/easy-parallel/src/ValueObject/ProcessPool.php(58): RectorPrefix202512\Symplify\EasyParallel\ValueObject\ProcessPool->quitProcess()
#2 [...]/vendor/rector/rector/src/Parallel/Application/ParallelFileProcessor.php(107): RectorPrefix202512\Symplify\EasyParallel\ValueObject\ProcessPool->quitAll()
#3 [...]/vendor/rector/rector/vendor/symplify/easy-parallel/src/ValueObject/ParallelProcess.php(96): Rector\Parallel\Application\ParallelFileProcessor->Rector\Parallel\Application\{closure}()
#4 [...]/vendor/rector/rector/vendor/react/event-loop/src/Timer/Timers.php(86): RectorPrefix202512\Symplify\EasyParallel\ValueObject\ParallelProcess->RectorPrefix202512\Symplify\EasyParallel\ValueObject\{closure}()
#5 [...]/vendor/rector/rector/vendor/react/event-loop/src/StreamSelectLoop.php(150): RectorPrefix202512\React\EventLoop\Timer\Timers->tick()
#6 [...]/vendor/rector/rector/src/Parallel/Application/ParallelFileProcessor.php(185): RectorPrefix202512\React\EventLoop\StreamSelectLoop->run()
#7 [...]/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(234): Rector\Parallel\Application\ParallelFileProcessor->process()
#8 [...]/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(126): Rector\Application\ApplicationFileProcessor->runParallel()
#9 [...]/vendor/rector/rector/src/Console/Command/ProcessCommand.php(172): Rector\Application\ApplicationFileProcessor->run()
#10 [...]/vendor/rector/rector/vendor/symfony/console/Command/Command.php(289): Rector\Console\Command\ProcessCommand->execute()
#11 [...]/vendor/rector/rector/vendor/symfony/console/Application.php(892): RectorPrefix202512\Symfony\Component\Console\Command\Command->run()
#12 [...]/vendor/rector/rector/vendor/symfony/console/Application.php(279): RectorPrefix202512\Symfony\Component\Console\Application->doRunCommand()
#13 [...]/vendor/rector/rector/src/Console/ConsoleApplication.php(60): RectorPrefix202512\Symfony\Component\Console\Application->doRun()
#14 [...]/vendor/rector/rector/vendor/symfony/console/Application.php(162): Rector\Console\ConsoleApplication->doRun()
#15 [...]/vendor/rector/rector/bin/rector.php(130): RectorPrefix202512\Symfony\Component\Console\Application->run()
#16 [...]/vendor/rector/rector/bin/rector(5): require_once('...')
#17 [...]/vendor/bin/rector(119): include('...')
#18 {main}
  thrown in [...]/vendor/rector/rector/vendor/symplify/easy-parallel/src/ValueObject/ParallelProcess.php on line 108

In my installation, the ParallelProcess.php:108 line corresponds to $this->encoder->end(), which seems like there's some kind of race condition where the subprocess is being closed before binding the connection.

I've been looking forward to making a contribution, but I can't come with a good decision without asking you: making the attribute nullable only feels like a little band aid, but a better solution would drastically change the API of ParallelProcess.

I wish I could show a reproducer, but it's happening on a private project and on an inconsistent basis, but I think the problem is very located here

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions