Circular reference detected for service "logger.channel.default"

Created on 16 October 2024, about 1 month ago

Problem/Motivation

Get error message:
Circular reference detected for service "logger.channel.default", path: "asset.js.collection_optimizer -> asset.js.optimizer -> logger.channel.default -> logger.factory -> logger.syslog -> ultimenu.manager -> renderer -> plugin.manager.element_info -> cache_tags.invalidator -> plugin.manager.block".

Steps to reproduce

Drupal 10.3.2
Upgarde ultimenu from 2.12 to 3.0.4
After upgrade and then run drush cr will get error

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

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

Comments & Activities

  • Issue created by @connbi
  • $manager = \Drupal::service('ultimenu.manager'); in ultimenu.module 23 line. service create failed.

  • 🇮🇩Indonesia gausarts

    Thank you.

    I haven't been able to see to it, nor have seen it before. But I understand your issue may be valid under certain circumstances about which I never had.

    In fact, we had this type of circular reference issue before in this project, and already fixed, although I didn't understand why that happened since it was triggered by another module, and never had it myself.

    Why? Because to my limited knowledge that issue happens when class A injects class B, and vice versa in circular reference. But we didn't see that in this module from the very beginning.

    We had even removed DI classes for the most parts previously just to solve something bogus aka I didn't understand, yet simply works.

    I suspected this is related to core issues somewhere but just haven't found the exact related issue for the proof :)

    About failing service instantiation, it must be related to your failing caches. Be sure to follow the Update SOP procedure at Blazy.

    This exact silly combo:

    drush cr
    drush updb
    drush cr

    After composer require ... never failed. If failed, be sure to update your drush, or see Update SOP for more.

    If you have more info, please share.

    • gausarts committed 22e7e6c7 on 3.0.x
      Issue #3481036 by connbi:   Circular reference detected for service "...
  • 🇮🇩Indonesia gausarts

    I couldn't reproduce it with my current environment, including after upgrades from 2.x to 3.x.
    See the other issue, which was triggered by another module existence.

    However I removed/changed potential issues accordingly, along with minor unrelated issues.

    We'll keep it open should anyone have a consistent reproduction. Then we'll close this if no more reproduction info.

  • I try to install blazy and then upgrade ultimenu in my site.
    my steps as below:

    1. drush en blazy -y
    2. drush cr
    3. composer require 'drupal/ultimenu:^3.0'
    4. drush updb
    5. drush cr

    and then I got error

    From the error message, I am also unable to identify which other module is conflicting with ultimenu or blazy.

  • 🇮🇩Indonesia gausarts

    > drush en blazy -y
    I think I understand your situation. You didn't have Blazy before upgrade?

    However to cover two scenarios, please follow both steps here.

    If you DON'T have Blazy before:
    Try downgrading to Ultimenu:2x first, install Blazy 2.x or 3.x, no problem here.

    composer require drupal/ultimenu:^2.0 drupal/blazy:^2.0 -W -n
    drush en blazy
    drush cr
    drush updb
    drushcr

    Downgrading modules doesn't pose issues, normally, as long you clear caches properly.
    Then follow the next step since you have blazy enabled above.

    If you DO have Blazy 2.x before:

    composer require drupal/ultimenu:^3.0 drupal/blazy:^3.0 -W -n
    drush cr
    drush updb
    drushcr

    Note I didn't run drush en blazy on the last step since Blazy was already install at first step.

    Just be sure this time it is blazy:3.x, not 2.x.
    More details are in Blazy upgrade steps.

  • Unfortunately, I tried the steps you mentioned above, but the error still occurred.

  • 🇮🇩Indonesia gausarts

    Just to be sure for repros:
    You didn't have Blazy before? Or you did have one?

    The drush en blazy assumed you didn't.

  • To clarify my situation, I have not previously installed Blazy, and Composer has never installed Blazy either. I only have version 2.10 of Ultimenu.

  • I followed the steps provided by @gausarts of the situation when I don't have blazy before.
    but there was no error reproduced to me.

    Thanks

  • I suspect this may be related to the simultaneous use of other modules, such as extlink. Of course, this is just my guess and has not been verified yet.

  • I checked the service references and found that asset.js.optimizer references logger.channel.default, and the plugin.manager.block in ultimenu.manager also references logger.channel.default. This should be the cause of the circular reference issue.

  • 🇮🇩Indonesia gausarts

    I am not sure, AFAIK, circular reference happens when class A extends class B, and vice versa, which is not the case here.

    Also the problem is both asset.js.optimizer and plugin.manager.block are core classes. We couldn't change them :)

    Previous solution was to move plugin.manager.block service out of DI into static service call, and solved another circular reference issue at D9-10.

    Now we have another different circular reference issue.

    Just a long shot, what about moving the plugin.manager.block in UltimenuBase::blockManager():
    https://git.drupalcode.org/project/ultimenu/-/blob/3.0.5/src/UltimenuBas...

    into just UltimenuManager:
    https://git.drupalcode.org/project/ultimenu/-/blob/3.0.5/src/UltimenuMan...

    UltimenuSkin previously referenced it, but later disabled it due to D12 compat, still marked as @todo.

    If that fixes the issue, it is likely the root cause.
    If not, at least one suspect down :)

    I was also thinking to decouple UltimenuSkin from UltimenuBase later, considering only three methods/services are being affected: ::config(), ::cache() and ::getPath(), and it should be fine to duplicate them in UltimenuSkin, only if necessary.

  • Based on the error message showing ultimenu.manager -> renderer -> plugin.manager.element_info -> cache_tags.invalidator -> plugin.manager.block, I noticed that renderer is injected in Blazy, which then enters the core cache part of Drupal. I have not yet found the code where cache_tags.invalidator injects into plugin.manager.block. Currently, I can confirm that it should not be related to the reference of plugin.manager.block in UltimenuBase.php, as I commented out that part of the code, and the error still persists.

  • Are there any new developments regarding this issue? Or is there a temporary solution to resolve the circular reference?
    @gausarts

  • 🇮🇩Indonesia gausarts

    Unfortunately, no. It would be possible to fix this if I could reproduce it.

    The problem is likely another module which triggers the issue, but I don't know nor have it.

    OP issue is similar to the other one, only different in the service.

    I would leave it open if anyone has the triggering module so I can figure out a reproduction.

    Feel free to share a solution. Thanks.

  • I disabled syslog. then upgrade ultimenu successfully.
    Once I enable syslog, this error will occur. @gausarts

  • I found the issue in the Drupal core issue queue at https://www.drupal.org/project/drupal/issues/3103620 🐛 Dependency on config storage causes circular reference in service container Needs review . Applying the patch fixed the circular reference problem. Thank you for your help! @gausarts

  • 🇮🇩Indonesia gausarts

    Weird, I always enable syslog, dev, stage or prod, and have never seen OP.

    However good find, thank you!

    Let's keep it open to avoid more dups.

Production build 0.71.5 2024