Problem/Motivation

I see the error while running any Drush command:

Circular reference detected for service "hook_event_dispatcher.module_handler", path: "hook_event_dispatcher.module_handler -> hook_event_dispatcher.manager -> event_dispatcher -> tracer.tracer -> tracer.tracer_
factory -> plugin.manager.tracer".

Drupal 10.1.2

I can't run any Drush command anymore

Steps to reproduce

In my I enabled hook_event_dispacther, core_event_dispatcher. Created custom EventSubscriber with using EntityHookEvents::ENTITY_VIEW => 'entityViewCallback' in getSubscribedEvents() function

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Luckie Joe created an issue. See original summary.

luckie joe’s picture

Issue summary: View changes
luckie joe’s picture

Issue summary: View changes
sillot’s picture

I also have the issue at the moment, but only when enabling Webprofiler, otherwise it was working well.

I'm going to test more.

cleverhoods’s picture

I think it's attached to this issue: https://www.drupal.org/project/tracer/issues/3387444
After installing the update for Tracer(1.0.1), the issue got sorted.

cleverhoods’s picture

~ duplicated comment ~

cleverhoods’s picture

The Tracer update didn't sort the issue out after all.
Hotfix patch is provided.

achap’s picture

This also only occurred for me once I installed webprofiler. hook_event_dispatcher was working fine before then. Given that this is the case for others as well maybe this issue should be closed in favour of the related one in tracer?

el7cosmos made their first commit to this issue’s fork.

  • el7cosmos committed 7ecac0e4 on 4.x
    Issue #3385203 by el7cosmos, cleverhoods, Luckie Joe: Circular reference...
el7cosmos’s picture

Status: Active » Fixed
el7cosmos’s picture

Version: 4.0.0-rc1 » 4.x-dev

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

bob.hinrichs’s picture

This problem has resurfaced for us:

hook_event_dispatcher: 4.2.0
tracer: 1.0.4
drupal core: 10.4.5
We are running lando with a pantheon recipe (if that matters).

When hook_event_dispatcher and tracer are enabled, and one runs drush updb, the following error results:

Circular reference detected for service "hook_event_dispatcher.module_handler", path: "hook_event_dispatcher.module_handler -> hook_event_dispatcher.manager -> hook_event_dispatcher.module_handler".

Some guesses as to why this is:

This error occurs during updb, because it has a special bootstrap mode that ensures all modules are loaded and update hooks are discovered in a single run, so it is instantiating the whole thing at once, and bringing the circular reference to light. Whereas in a normal page request, some services are only loaded on demand.

Tracer’s services include:

plugin.manager.tracer:
class: Drupal\tracer\TracerPluginManager
parent: default_plugin_manager

TracerPluginManager extends Drupal’s DefaultPluginManager. That core base class automatically loads the module_handler. If you then have a circular dependency from module_handler → hook_event_dispatcher.manager → module_handler, enabling Tracer is the catalyst that triggers it during drush updb. \Drupal\tracer\TracerPluginManager extends DefaultPluginManager and calls parent::__construct. This parent class requires module_handler.

I will add a comment to the linked tracer issue, since I don't have enough understanding to know where the fix would reside, if a fix is possible.

Curious to see if this is reproducible by others.

bob.hinrichs’s picture

Version: 4.x-dev » 4.2.0