Skip to content

[Parallel] Guard uninitialized encoder in ParallelProcess::quit() - #8461

Open
TomasVotruba wants to merge 1 commit into
mainfrom
fix-parallel-encoder-uninitialized
Open

[Parallel] Guard uninitialized encoder in ParallelProcess::quit()#8461
TomasVotruba wants to merge 1 commit into
mainfrom
fix-parallel-encoder-uninitialized

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Fixes rectorphp/rector#9885

Problem

Running with a high withParallel() worker count crashes near the end:

Fatal error: Uncaught Error: Typed property Rector\Parallel\ValueObject\ParallelProcess::$encoder must not be accessed before initialization

Cause

A ParallelProcess is spawned via start() and attached to the pool immediately, but its $encoder is set only later in bindConnection(), once the child connects over TCP and sends HELLO.

When an error occurs (e.g. a job timeout), handleErrorCallable calls ProcessPool::quitAll(), which invokes quit() on every pooled process, including those spawned but not yet bound. Those have no $encoder, so $this->encoder->end() throws.

With many more workers than needed (the report uses withParallel(360)), plenty of processes sit in the pool unbound when quitAll() fires.

Fix

Guard the encoder access in quit() with isset(), so an unbound process quits cleanly.

https://claude.ai/code/session_01BhpDMF7ffeFv6sjaPqEZzc

A process spawned into the pool but not yet bound to its connection has no
encoder set. When quitAll() runs after an error (e.g. timeout) it calls quit()
on every pooled process, hitting "Typed property $encoder must not be accessed
before initialization". Guard the encoder access.

Fixes rectorphp/rector#9885

Claude-Session: https://claude.ai/code/session_01BhpDMF7ffeFv6sjaPqEZzc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Fatal error: Uncaught Error: Typed property Rector\Parallel\ValueObject\ParallelProcess::$encoder must not be accessed before initialization

1 participant