RuntimeException: Recursive router rebuild detected.

Created on 19 August 2021, almost 3 years ago
Updated 19 November 2023, 7 months ago

Problem/Motivation

This is a tricky one and took me time to figure out... Installing a module defining JSON API resources during site install such as Commerce API can trigger a

RuntimeException: Recursive router rebuild detected.

exception.

This seems to be caused by the exceptions thrown from ResourceRoutes::ensureResourceImplementationValid() by the following check:

    elseif (empty($route->getDefault('_jsonapi_resource_types'))) {
      throw new RouteDefinitionException("The $route_name route definition's _jsonapi_resource_types route default must declare at least one resource type.");
    }

For some reason, during the installation, the following:

    $order_resource_types = $this->getResourceTypesForEntityType('commerce_order');

returns an empty array causing the exception to be thrown which seems to trigger a router rebuild.

🐛 Bug report
Status

Closed: works as designed

Version

1.0

Component

Code

Created by

🇮🇱Israel jsacksick

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024