Skip to content
Snippets Groups Projects
Commit cb0a7995 authored by catch's avatar catch
Browse files

Issue #3390178 by godotislate, larowlan, catch, pixlkat, Utilvideo, rsnyd, Wim...

Issue #3390178 by godotislate, larowlan, catch, pixlkat, Utilvideo, rsnyd, Wim Leers, cilefen, smustgrave, fjgarlin, jakegibs617, seixas, mohithasmukh, very_random_man: big_pipe sometimes fails to load blocks

(cherry picked from commit dcf27ba1)
parent 257ca110
No related branches found
No related tags found
15 merge requests!8376Drupal views: adding more granularity to the ‘use ajax’ functionality,!8300Issue #3443586 View area displays even when parent view has no results.,!7567Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7565Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7509Change label "Block description" to "Block type",!7344Issue #3292350 by O'Briat, KlemenDEV, hswong3i, smustgrave, quietone: Update...,!6922Issue #3412959 by quietone, smustgrave, longwave: Fix 12 'un' words,!6848Issue #3417553 by longwave: Remove withConsecutive() in CacheCollectorTest,!6720Revert "Issue #3358581 by pfrenssen, _tarik_, a.dmitriiev, smustgrave:...,!6560Update ClaroPreRender.php, confirming classes provided are in array format,!6528Issue #3414261 by catch: Add authenticated user umami performance tests,!6501Issue #3263668 by omkar-pd, Wim Leers, hooroomoo: Re-enable inline form errors...,!6354Draft: Issue #3380392 by phma: Updating language weight from the overview reverts label if translated,!6324Issue #3416723 by Ludo.R: Provide a "node type" views default argument,!6119Issue #3405704 by Spokje, longwave: symfony/psr-http-message-bridge major version bump
Pipeline #71223 passed
Pipeline: drupal

#71224

    ......@@ -92,7 +92,10 @@
    node.nodeType === Node.ELEMENT_NODE &&
    node.nodeName === 'SCRIPT' &&
    node.dataset &&
    node.dataset.bigPipeReplacementForPlaceholderWithId,
    node.dataset.bigPipeReplacementForPlaceholderWithId &&
    typeof drupalSettings.bigPipePlaceholderIds[
    node.dataset.bigPipeReplacementForPlaceholderWithId
    ] !== 'undefined',
    );
    }
    ......@@ -106,6 +109,13 @@
    if (checkMutation(node)) {
    processReplacement(node);
    }
    // Checks if parent node of target node has not been processed, which can
    // occur if the script node was first observed with empty content and then
    // the child text node was added in full later.
    // @see `@ingroup large_chunk` for more information.
    else if (checkMutation(node.parentNode)) {
    processReplacement(node.parentNode);
    }
    }
    /**
    ......
    ......@@ -19,3 +19,10 @@ big_pipe_test_large_content:
    _title: 'BigPipe test large content'
    requirements:
    _access: 'TRUE'
    big_pipe_test_multiple_replacements:
    path: '/big_pipe_test_multiple_replacements'
    defaults:
    _controller: '\Drupal\big_pipe_regression_test\BigPipeRegressionTestController::multipleReplacements'
    requirements:
    _access: 'TRUE'
    ......@@ -3,12 +3,15 @@
    namespace Drupal\big_pipe_regression_test;
    use Drupal\big_pipe\Render\BigPipeMarkup;
    use Drupal\Component\Utility\Random;
    use Drupal\Core\Security\TrustedCallbackInterface;
    class BigPipeRegressionTestController implements TrustedCallbackInterface {
    const MARKER_2678662 = '<script>var hitsTheFloor = "</body>";</script>';
    const PLACEHOLDER_COUNT = 3000;
    /**
    * @see \Drupal\Tests\big_pipe\FunctionalJavascript\BigPipeRegressionTest::testMultipleBodies_2678662()
    */
    ......@@ -46,6 +49,23 @@ public function largeContent() {
    ];
    }
    /**
    * A page with multiple nodes.
    *
    * @see \Drupal\Tests\big_pipe\FunctionalJavascript\BigPipeRegressionTest::testMultipleReplacements
    */
    public function multipleReplacements() {
    $build = [];
    foreach (range(1, self::PLACEHOLDER_COUNT) as $length) {
    $build[] = [
    '#lazy_builder' => [static::class . '::renderRandomSentence', [$length]],
    '#create_placeholder' => TRUE,
    ];
    }
    return $build;
    }
    /**
    * Renders large content.
    *
    ......@@ -70,11 +90,24 @@ public static function currentTime() {
    ];
    }
    /**
    * Renders a random length sentence.
    *
    * @param int $length
    * The sentence length.
    *
    * @return array
    * Render array.
    */
    public static function renderRandomSentence(int $length): array {
    return ['#cache' => ['max-age' => 0], '#markup' => (new Random())->sentences($length)];
    }
    /**
    * {@inheritdoc}
    */
    public static function trustedCallbacks() {
    return ['currentTime', 'largeContentBuilder'];
    return ['currentTime', 'largeContentBuilder', 'renderRandomSentence'];
    }
    }
    ......@@ -150,4 +150,27 @@ public function testBigPipeLargeContent() {
    $assert_session->elementExists('css', '#big-pipe-large-content');
    }
    /**
    * Test BigPipe replacement of multiple complex replacements.
    *
    * In some situations with either a large number of replacements or multiple
    * replacements involving complex operations, some replacements were not
    * completed. This is a simulation of such a situation by rendering a lot of
    * placeholders on a page.
    *
    * @see https://www.drupal.org/node/3390178
    */
    public function testMultipleReplacements(): void {
    $user = $this->drupalCreateUser();
    $this->drupalLogin($user);
    $assert_session = $this->assertSession();
    $this->drupalGet(Url::fromRoute('big_pipe_test_multiple_replacements'));
    $this->assertNotNull($assert_session->waitForElement('css', 'script[data-big-pipe-event="stop"]'));
    $this->assertCount(0, $this->getDrupalSettings()['bigPipePlaceholderIds']);
    $this->assertCount(0, $this->getSession()->getPage()->findAll('css', 'span[data-big-pipe-placeholder-id]'));
    $this->assertCount(BigPipeRegressionTestController::PLACEHOLDER_COUNT + 1, $this->getSession()->getPage()->findAll('css', 'script[data-big-pipe-replacement-for-placeholder-with-id]'));
    }
    }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment