Skip to content

kernel.reset clears schemas permanently in worker mode (FrankenPHP/RoadRunner) #1242

@benji07

Description

@benji07

Description

Since PR #1203 (v1.8.0+), the Executor service is tagged with kernel.reset, and its reset() method clears $this->schemas = [].

However, addSchemaBuilder() is only called once during container compilation. After the first request in worker mode (FrankenPHP, RoadRunner), the kernel.reset event fires and permanently clears all registered schemas. Every subsequent request handled by the same worker fails with:

RuntimeException: At least one schema should be declared.

Steps to reproduce

  1. Use FrankenPHP in worker mode (or RoadRunner)
  2. Configure a GraphQL schema as usual
  3. Send a first request → 200 OK
  4. Send a second request → 500 "At least one schema should be declared."

Proof

$kernel = new App\Kernel('prod', false);
$kernel->boot();
$container = $kernel->getContainer();
$executor = $container->get('overblog_graphql.request_executor');

echo count($executor->getSchemasNames()); // 1

$kernel->handle($request);
echo count($executor->getSchemasNames()); // 1 (first request OK)

$kernel->handle($request);
echo count($executor->getSchemasNames()); // 0 ← schemas lost after reset

Root cause

In Executor.php:

public function reset(): void
{
    $this->schemas = [];
}

The schemas are registered via addSchemaBuilder() calls from the compiled container, but after reset() they are never re-registered.

The same issue applies to TypeResolver::reset().

Suggested fix

The reset() method should preserve schema builders registered at compile time. For example, by saving the initial schemas and restoring them on reset:

private array $initialSchemas = [];

public function addSchemaBuilder(string $name, Closure $builder): self
{
    $this->schemas[$name] = $builder;
    $this->initialSchemas[$name] = $builder;
    return $this;
}

public function reset(): void
{
    $this->schemas = $this->initialSchemas;
}

Versions

  • overblog/graphql-bundle: v1.9.0
  • PHP: 8.4
  • FrankenPHP: v1.12.1
  • Symfony: 7.3

Workaround

Downgrade to v1.7.x (before #1203) or remove the kernel.reset tag via a compiler pass.

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