I am frequently seeing module installation and uninstallation fail with the error
Uncaught PHP Exception RuntimeException: "Recursive router rebuild detected." at /path/to/drupal/web/core/lib/Drupal/Core/Routing/RouteBuilder.php line 121
It seems the underlying problem is that something goes wrong, and the way that the error is handled tries to get router information that is already being changed.
Is the fact that it's producing this fatal WSOD exception a core bug? Or is this one of those things where they will always pass responsibility to whatever is causing the original error? Is there a good way to diagnose these problems?
It leaves the modules half-installed, like with entity types registered but no schema. It's not great.
An example error:
The website encountered an unexpected error. Please try again later.
RuntimeException: Recursive router rebuild detected. in Drupal\Core\Routing\RouteBuilder->rebuild() (line 121 of core/lib/Drupal/Core/Routing/RouteBuilder.php).
Drupal\Core\ProxyClass\Routing\RouteBuilder->rebuild() (Line: 67)
Drupal\Core\Routing\RouteProviderLazyBuilder->getRouteProvider() (Line: 104)
Drupal\Core\Routing\RouteProviderLazyBuilder->getRoutesByPattern() (Line: 115)
Drupal\devel\EntityTypeInfo->getPathParts() (Line: 100)
Drupal\devel\EntityTypeInfo->setEntityTypeLinkTemplate() (Line: 75)
Drupal\devel\EntityTypeInfo->entityTypeAlter() (Line: 94)
devel_entity_type_alter() (Line: 539)
Drupal\Core\Extension\ModuleHandler->alter() (Line: 334)
Drupal\Core\Plugin\DefaultPluginManager->alterDefinitions() (Line: 127)
Drupal\Core\Entity\EntityTypeManager->findDefinitions() (Line: 175)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 22)
Drupal\Core\Plugin\DefaultPluginManager->getDefinition() (Line: 136)
Drupal\Core\Entity\EntityTypeManager->getDefinition() (Line: 257)
Drupal\Core\Entity\EntityTypeManager->getHandler() (Line: 196)
Drupal\Core\Entity\EntityTypeManager->getStorage() (Line: 497)
Drupal\Core\Entity\EntityBase::loadMultiple() (Line: 19)
Drupal\ggroup\Routing\SubgroupRouteProvider->getRoutes()
call_user_func() (Line: 146)
Drupal\Core\Routing\RouteBuilder->rebuild() (Line: 83)
Drupal\Core\ProxyClass\Routing\RouteBuilder->rebuild() (Line: 67)
Drupal\Core\Routing\RouteProviderLazyBuilder->getRouteProvider() (Line: 104)
Drupal\Core\Routing\RouteProviderLazyBuilder->getRoutesByPattern() (Line: 115)
Drupal\devel\EntityTypeInfo->getPathParts() (Line: 100)
Drupal\devel\EntityTypeInfo->setEntityTypeLinkTemplate() (Line: 75)
Drupal\devel\EntityTypeInfo->entityTypeAlter() (Line: 94)
devel_entity_type_alter() (Line: 539)
Drupal\Core\Extension\ModuleHandler->alter() (Line: 334)
Drupal\Core\Plugin\DefaultPluginManager->alterDefinitions() (Line: 127)
Drupal\Core\Entity\EntityTypeManager->findDefinitions() (Line: 175)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 22)
Drupal\Core\Plugin\DefaultPluginManager->getDefinition() (Line: 136)
Drupal\Core\Entity\EntityTypeManager->getDefinition() (Line: 257)
Drupal\Core\Entity\EntityTypeManager->getHandler() (Line: 196)
Drupal\Core\Entity\EntityTypeManager->getStorage() (Line: 247)
Drupal\views\EventSubscriber\ViewsEntitySchemaSubscriber->onEntityTypeDelete() (Line: 51)
Drupal\views\EventSubscriber\ViewsEntitySchemaSubscriber->onEntityTypeEvent()
call_user_func() (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 145)
Drupal\Core\Entity\EntityTypeListener->onEntityTypeDelete() (Line: 167)
Drupal\Core\Entity\EntityDefinitionUpdateManager->uninstallEntityType() (Line: 490)
Drupal\Core\Extension\ModuleInstaller->uninstall() (Line: 91)
Drupal\Core\ProxyClass\Extension\ModuleInstaller->uninstall() (Line: 174)
Drupal\system\Form\ModulesUninstallConfirmForm->submitForm()
call_user_func_array() (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 592)
Drupal\Core\Form\FormBuilder->processForm() (Line: 320)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 23)
Stack\StackedHttpKernel->handle() (Line: 708)
Drupal\Core\DrupalKernel->handle() (Line: 19)