Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

SkolemIriConverter isn't reset between requests in worker mode (missing kernel.reset tag)

オープン 初心者向け
#8,680 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@silverbackdan がすでに取り組んでいます。

2026年10月13日 から。

  • #8681 @silverbackdan による — オープン

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
85/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php
領域
api

調査の方向性

Symfony バンドルの設定にある api_platform.symfony.iri_converter.skolem のサービス定義から始め、ResetInterface を実装し objectHashMap プロパティを保持している SkolemIriConverter を確認してください。このサービスに kernel.reset タグが欠けていないかを確かめ、その後リセット呼び出しが services_resetter 経由で接続されていることを確認します。再現コードの skolem マップが、リセットのたびに空になれば完了です。

索引モデルが issue の本文から書いたものです。

説明

API Platform version(s) affected: 5.0.2 (also 4.4 and main)

Description
I've been upgrading one of our projects to API Platform 5 (Symfony 8.1, FrankenPHP in worker mode). One endpoint returns embedded objects that aren't resources themselves, so they get /.well-known/genid/... IRIs. With that endpoint, a single worker's memory kept growing until it hit our 128M memory_limit. It only took about five requests.

it seems the skolem IRI converter keeps an object → IRI map, and it is never cleared between requests.

I think the cause is that SkolemIriConverter already implements ResetInterface, but its service (api_platform.symfony.iri_converter.skolem) isn't tagged kernel.reset, so services_resetter never calls it. As far as I can see, it's the same in 4.4, 5.0 and main.

How to reproduce

  1. Create a resource that returns an embedded object which isn't itself a resource, so it gets a genid IRI. For example:
#[ApiResource(operations: [new Get(provider: [self::class, 'provide'])])]
final class Report
{
    public string $id = '1';
    /** @var Line[] */
    public array $lines = [];

    public static function provide(): self
    {
        $r = new self();
        foreach (range(1, 500) as $i) {
            $r->lines[] = new Line(str_repeat('x', 1000));
        }

        return $r;
    }
}

final class Line
{
    public function __construct(public string $text) {}
}
  1. Boot the kernel once and send several requests through it. Run the services resetter between them, as a FrankenPHP worker would:
$kernel = new Kernel('prod', false);
$kernel->boot();
$skolem = $kernel->getContainer()->get('api_platform.symfony.iri_converter.skolem');
$map = (new \ReflectionProperty($skolem, 'objectHashMap'));

for ($i = 1; $i <= 5; $i++) {
    $response = $kernel->handle(Request::create('/reports/1', 'GET', server: ['HTTP_ACCEPT' => 'application/ld+json']));
    $kernel->terminate($request ?? Request::create('/'), $response);
    $kernel->getContainer()->get('services_resetter')->reset();

    printf("request %d: %d skolem entries, %.1f MB\n", $i, count($map->getValue($skolem)), memory_get_usage() / 1048576);
}
  1. Expected: the skolem map is empty, or at least stays flat, after each reset. What happens: it grows by the number of embedded objects on every request (500, 1000, 1500, …), and memory grows with it. In our app it reached the 128M limit within about five requests.
  2. Add the kernel.reset tag (see the workaround below) and run it again. The map is cleared after each request, and memory stays flat.

Possible Solution
Add the tag where the service is registered:

->tag('kernel.reset', ['method' => 'reset'])

Additional Context
Workaround for now

override the service definition ourselves for api_platform.symfony.iri_converter.skolem to add the tag

With that in place, memory stays flat across requests.

I'll raise a short PR

主要言語
PHP
スター
2.6k
フォーク
989
平均マージ
2日 4時間
マージ済み PR(30日)
90

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

api-platform/core のほかの issue

api-platform/core の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。