LogicException: leaked metadata was detected

Created on 17 January 2023, over 1 year ago
Updated 18 January 2023, over 1 year ago

Problem/Motivation

Hi all, sorry for my bad english.

I use drupal as Identity for a frontend in next.js with the "Authorization Code Grant".
After upgrading core and various contrib modules i have the following exception at login:

LogicException: The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\Core\Routing\TrustedRedirectResponse. in Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (line 154 of core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php).

Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 68)
Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 49)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 713)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

there are many issues on drupal.org that talk about it and the most interesting is the following 📌 Exception in EarlyRenderingControllerWrapperSubscriber is a DX nightmare, remove it Needs work

these are versions of a selection of installed modules:

After some "debugging" I noticed that the problem doesn't arise using version 1.4.0 of the next module, but looking at the changes made from version 1.4.0 to 1.6.2 I can't figure out what could cause this problem.

The only way I found to make the login process work with the versions listed above, was to apply the patch (which I will attach in the next comment) to the simple_oauth Oauth2AuthorizeController::redirectToCallback method, but I'm wondering if these changes can lead to other types of problems.

Any suggestions on the possible cause or on the created patch are welcome, thank you

🐛 Bug report
Status

Postponed: needs info

Version

5.2

Component

Code

Created by

🇮🇹Italy robertom

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.

  • Status changed to Closed: works as designed over 1 year ago
  • Status changed to Active over 1 year ago
  • Status changed to Postponed: needs info over 1 year ago
Production build 0.69.0 2024