Duplicate values in ajaxPageState.libraries

Created on 11 April 2017, over 7 years ago
Updated 29 August 2024, 3 months 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

Needs work

Version

11.0 πŸ”₯

Component
AjaxΒ  β†’

Last updated about 14 hours 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

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.

Production build 0.71.5 2024