Duplicate values in ajaxPageState.libraries

Created on 11 April 2017, over 7 years ago
Updated 7 April 2023, over 1 year ago

If a library is added during an ajax request, the drupalSettings.ajaxPageState.libraries contains duplicate values.

This is a performance issue when using POST ajax request but becomes an major issue if the ajax is made with GET because after each ajax request the URI for the next ajax request becomes larger and at some point it becomes larger than allowed and a "414 Request-URI Too Large" is possible.

🐛 Bug report
Status

Closed: outdated

Version

10.1

Component
Ajax 

Last updated 3 days ago

Created by

🇩🇪Germany braindrift

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States smustgrave

    Closing out as outdated per #20.

    Not something that's been noticed I believe/reproducible.

  • Status changed to Active over 1 year ago
  • 🇩🇪Germany mkalkbrenner 🇩🇪

    I just updated a site from Drupal 9.5.10 to 10.1.0 and run into this error now.

    I debugged the issue and found that views/views.module is added twice.

  • 🇩🇪Germany mkalkbrenner 🇩🇪

    In Drupal\Core\Render\HtmlResponseAttachmentsProcessor::processAttachments():

    $ajax_page_state = $this->requestStack->getCurrentRequest()->get('ajax_page_state');
    

    This page state contains views/views.module two times.

  • Status changed to Needs work over 1 year ago
  • 🇩🇪Germany mkalkbrenner 🇩🇪

    This quick fix made the site work in the dev environment.

  • 🇩🇪Germany mkalkbrenner 🇩🇪

    Also happens with 10.1.1.
    But it is interesting that it wasn't an issue with 9.5.x.

  • 🇩🇪Germany IT-Cru Munich

    @mkalkbrenner: Maybe HTTP method for AJAX requests has changed to GET in D10 or D10.1? This was in the past our problem, because we used some patch I think to have GET instead of POST request for AJAX in our project.

    Could you double check this? As mentioned in #21 with switch to a decoupled frontend we do not trigger such AJAX requests in our project anymore.

  • 🇦🇺Australia thtas

    I've just run in to this too. Annoyingly it only seems to manifest during gitlab ci test runs, so tricky to debug.

    We're not doing any ajax requests, and the problem goes away when I disable big_pipe.

    The library which is being added twice is "facets/drupal.facets.link-widget" (and it's duplicated at the end of the libraries array).

  • 🇧🇪Belgium kwinten-hardies Vlaams-Brabant

    Looks like this is still the case with Drupal 11.0.1 too. I just tested this on a standard install of Drupal 11 with only media en media_browser enabled as extra.
    When filtering and paginating, the query parameters are duplicated. resulting in a "request URI too long" error on our firewall.

    From 10.2.3 onwards this is a problem for all our site's. I found a lot of issues regarding this but all proposed solutions do not work.
    Could this be a nginx problem? But I tried this on a docker-drupal setup with apache and it's the same there.

    I just don't know where to look in ajax code. Please advise. Thank you.

  • 🇮🇳India mohit_aghera Rajkot

    I also noticed this issue while working on the project.
    Drupal core: 10.3.10
    Issue was noticed on layout builder edit form where core/components.navigation--toolbar-button library was added twice.

    Upon debugging, I noticed that it is present twice in ajax_page_state as well.

    I think we should apply array_unique when we push the libraries to ajax_page_state so we always have unique libraries in the ajax_page_state.

    I've added a PR with the fix.

  • Merge request !10389Duplicate values in ajaxPageState.libraries → (Open) created by mohit_aghera
  • Pipeline finished with Success
    27 days ago
    Total: 561s
    #353921
  • 🇮🇳India mohit_aghera Rajkot

    Adding patch for the 10.3.x release cycle since current 11.x patch is not cleanly applied on 10.3.x.

Production build 0.71.5 2024