Adding too many Views blocks to a Layout Builder page in Drupal 10.2 can break Ajax

Created on 3 April 2024, 11 months ago
Updated 28 June 2024, 8 months ago

Problem/Motivation

I'm not sure if it's specific to our setup, but I don't think it is since we aren't hacking Layout Builder. We are using it mostly as it is provided by core. We do use these LB modules:
* Layout Builder Component Attributes
* Layout Builder Lock
* Layout Builder Operation Link
* Layout Builder Restrictions
* Layout Builder Restrictions by Region
* Layout Builder Styles
* Layout Builder Claro
* Layout Builder Iframe Modal

At first, we thought the error only happened when adding too many blocks of any kind. But, in further diving, it turns out the issue only happens when we add 5-7 Views blocks to a LB page. We can add 10+ non-Views blocks without issue, but as soon as we add 5-7 Views blocks, the issue arises again.

I think there is some performance bottleneck with the Layout Builder + Views blocks integration, that seemingly seems to have appeared in Drupal 10.2, because I have tested on 10.1 and the issue isn't present.

Steps to reproduce

Try adding 10 views blocks (from the Lists (Views) section of the LB blocks list) onto a LB page.
At some point, you may encounter a JS error (in my case, I had 2 though).

iframe.js?sbcpjn:11 Uncaught TypeError: Cannot read properties of undefined (reading 'prototype')
    at iframe.js?sbcpjn:11:23
    at iframe.js?sbcpjn:84:3

(This is specific to the Layout Builder Iframe Modal module we are using, but I think it's being caused by some other root cause)

An error occurred during the execution of the Ajax response: LoadJS

If not using Layout Builder Iframe Modal and just using core's off-canvas for adding/selecting blocks, in that case, I was running into this error:

ResponseText: 
414 Request-URI Too Long
Request-URI Too Long
The requested URL's length exceeds the capacity
limit for this server.

Proposed resolution

Not sure, make it so Views blocks aren't so heavy when integrated into Layout Builder. I assume these blocks are heavier than normal blocks, and maybe there's metadata or whatnot we can not include to bring minimize their footprint.

I've linked various tickets that I've come across that seem possibly related, but it seems like a complicated issue with an unknown root cause.

Also, since I can't linked it, this is also this 10.2 Change Record that I wanted to note that may be related to the content length error:
https://www.drupal.org/node/3298551

It's also worth mentioning that since this issue seems specific to Views blocks, driven my project-specific Views, not all sites may be encountering the same issues. We may have more robust views with more content than typical sites. So while 7 Views blocks causes our JS error, it may take other sites with less complicated/robust setups more Views blocks to replicate the same issue.

🐛 Bug report
Status

Postponed: needs info

Version

11.0 🔥

Component
Layout builder 

Last updated about 8 hours ago

Created by

🇺🇸United States joshua.boltz

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

Comments & Activities

  • Issue created by @joshua.boltz
  • Status changed to Postponed: needs info 11 months ago
  • 🇳🇿New Zealand danielveza Brisbane, AU

    Thanks for the very detailed issue! As you mention your site is very specific with a lot on content with many extra LB modules enabled.

    That makes this quite difficult to trace down if this is an issue in core or somewhere else in your stack. It would be helpful if you were able to replicate this with just core. Maybe you could try use Devel & Devel generate to make a ton of content and try get this to trigger? I spent some time today trying this but had no luck.

    ResponseText:
    414 Request-URI Too Long
    Request-URI Too Long
    The requested URL's length exceeds the capacity
    limit for this server.

    It could potentially help if you could share the URL that was generated here?

  • 🇺🇸United States xjm
  • 🇫🇮Finland phonkala

    This comment might be completely unrelated, but I was just recently getting some LoadJS error when adding specifically Views blocks to my site. There was also lots other JS "undefined" errors whenever this happened. Also, this caused modules like Contextual Links & Layout Builder to stop working correctly and also there was something weird happening in the UI.

    My issue ended up being a missing tag in one Views block, I was using custom formatting for the output. This for some reason caused so so many issues on the site, including the JS errors and for some weird reason, also my Olivero sidebar was placed inside those tags (even though the Views blocks were in main content area), causing issues with the site theme and breaking many UI related modules.

    What I was thinking, maybe the "The requested URL's length exceeds the capacity limit for this server." you mentioned could be causing this too. If the server limits the request url length, you obviously aren't getting the response you expect, maybe that could cause similar issue I had.

    You might wanna try removing the blocks one by one and see if it's some specific one that is causing the issue. But anyways, just wanted to add a comment in case this would help figuring out the issue even a bit.

Production build 0.71.5 2024