After clearing Drupal's cache trying to retrieve a webform via REST as a user other than user 1 results in the following error:

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\rest\ResourceResponse. in Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (line 154 of core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php).

After viewing the webform as user 1 normally under admin/structure/webforms the webform is available via REST again to the the other users.

Returning a ModifiedResourceResponse instead of ResourceResponse might get around it, at the expense of some caching I think.

Comments

imclean created an issue. See original summary.

imclean’s picture

Issue summary: View changes
imclean’s picture

Issue summary: View changes
imclean’s picture

Issue summary: View changes
imclean’s picture

Leaky cache contexts include the following:

Custom form:

  • node_grants:view

Contact form:

  • config:system.site
  • config:webform.webform.contact
  • user:8
  • webform:contact

For such a simple module as this, it's too tricky to work out everything which might be cached and add it to the response.

  • imclean committed 331b276 on 8.x-1.x
    Issue #2901963 by imclean: Fetching a webform after clearing cache...
imclean’s picture

Status: Active » Fixed

Using ModifiedResourceResponse instead of ResourceResponse.

Status: Fixed » Closed (fixed)

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