fix(symfony): ensure ErrorListener is fully stateless to prevent stat…#7921
Open
KevinMartinsDev wants to merge 1 commit intoapi-platform:mainfrom
Open
fix(symfony): ensure ErrorListener is fully stateless to prevent stat…#7921KevinMartinsDev wants to merge 1 commit intoapi-platform:mainfrom
KevinMartinsDev wants to merge 1 commit intoapi-platform:mainfrom
Conversation
…e contamination in Worker mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR is the third part of the worker mode compatibility audit (see #7918). It refactors the
ErrorListenerto be strictly stateless.The Issue
The
ErrorListenerpreviously stored the target controller in a private property during the request duplication process. In persistent memory runtimes (FrankenPHP, Swoole, etc.):$controllerproperty was mutated. If not properly reset (and it wasn't), the next error handled by the same worker could inherit the previous request's controller.The Solution
The listener has been refactored to remove the mutable
$controllerproperty entirely:duplicateRequest.parent::duplicateRequest($exception, $request)when we need to delegate to Symfony, without modifying the listener's internal state.private, removing it does not break the public API. The constructor signature remains unchanged for backward compatibility.This ensures that every error handled by the worker starts with a "clean slate", regardless of what happened in previous requests.