[random test failure] LayoutBuilderBlocksTest::testBlockPlaceholder failing

Created on 28 September 2024, about 2 months ago

Problem/Motivation

    Drupal\Tests\layout_builder\Functional\LayoutBuilderBlocksTest::testBlockPlaceholder
    Behat\Mink\Exception\ResponseTextException: The text "Placeholder for the
    "The block label" block" appears in the text of this page, but it should
    not.
I just ran into this and GitLab CI notes that this test "Failed 15 times in 11.x in the last 14 days" so this one probably needs an issue to investigate.

@longwave and @quietone in 2829040-202 🌱 [meta] Known intermittent, random, and environment-specific test failures Active and 203.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

phpunit

Created by

🇳🇱Netherlands spokje

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

Merge Requests

Comments & Activities

  • Issue created by @spokje
  • Pipeline finished with Success
    about 2 months ago
    Total: 1307s
    #295592
  • 🇳🇱Netherlands spokje

    So MR!9676 (https://git.drupalcode.org/issue/drupal-3477586/-/jobs/2891429) shows that this test fails ~26/1500 runs.

  • Pipeline finished with Success
    about 2 months ago
    Total: 989s
    #295993
  • 🇳🇱Netherlands spokje

    At first glance, I can think of two ways the placeholder is not replaced:

    1. Setting the $block_content in \Drupal::state() goes wrong/causes a race condition
    2. The "magic" in \Drupal\layout_builder\EventSubscriber\BlockComponentRenderArray::onBuildRender does something unexpected and we end up in the if ($is_content_empty && $is_placeholder_ready) where we set the placeholder again, with similar content as the original one.

    Let's assert both.

  • Pipeline finished with Success
    about 2 months ago
    Total: 689s
    #296030
  • 🇳🇱Netherlands spokje

    So looking at all the test failures being:

    Drupal\Tests\layout_builder\Functional\LayoutBuilderBlocksTest::testBlockPlaceholder
        Behat\Mink\Exception\ResponseTextException: The text "is_content_empty &&
        is_placeholder_ready Placeholder for the "The block label" block" appears
        in the text of this page, but it should not.
    

    I think we can safely say it's #2.

  • Pipeline finished with Failed
    about 2 months ago
    Total: 197s
    #296036
  • 🇳🇱Netherlands spokje

    $content = $block->build() in \Drupal\layout_builder\EventSubscriber\BlockComponentRenderArray::onBuildRender ends up in \Drupal\layout_builder\Plugin\Block\ExtraFieldBlock::build.

    The only way I can see that returning empty would be if we land in this if-branch:
    if (!isset($extra_fields['display'][$this->fieldName])).

    Which in turn would mean \Drupal\Core\Entity\EntityFieldManager::getExtraFields would return an array without $extra_fields['display'][$this->fieldName], which would mean in \Drupal\Core\Entity\EntityFieldManager::getExtraFields, $this->extraFields[$entity_type_id][$bundle] would not be set.

  • 🇳🇱Netherlands spokje

    This is where it ends for me, I really have no idea what's happening to cause the random failure.

Production build 0.71.5 2024