Skip to content

feat(openapi): implement ResetInterface in OpenApiFactory#7922

Open
KevinMartinsDev wants to merge 2 commits intoapi-platform:mainfrom
KevinMartinsDev:feat/reset-interface-openapi-factory
Open

feat(openapi): implement ResetInterface in OpenApiFactory#7922
KevinMartinsDev wants to merge 2 commits intoapi-platform:mainfrom
KevinMartinsDev:feat/reset-interface-openapi-factory

Conversation

@KevinMartinsDev
Copy link
Copy Markdown

@KevinMartinsDev KevinMartinsDev commented Apr 19, 2026

Description

This PR is the fourth part of the worker mode compatibility audit (see #7918). It implements ResetInterface in OpenApiFactory to handle internal state persistence.

The Issue

OpenApiFactory is a singleton service that maintains two types of internal state:

  1. Route Collection Cache: Once the router is accessed, the RouteCollection is stored in a private property.
  2. Local Error Resource Cache: A private array ($localErrorResourceCache) that stores resolved error resources to avoid redundant processing.

In persistent memory environments like FrankenPHP:

  • Stale Data: If routes are modified or dynamically updated, the factory might keep using the old cached RouteCollection until the worker restarts.
  • Memory Growth: The error resource cache grows with every unique error encountered, leading to an unbounded increase in RAM usage over time.

The Solution

By implementing Symfony\Contracts\Service\ResetInterface, we ensure that:

  • $routeCollection is reset to null.
  • $localErrorResourceCache is cleared (reset to []).

This happens automatically after each request in worker mode, ensuring that the next request starts with fresh metadata and a clean memory footprint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant