Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with big_pipe #258

Open
Berdir opened this issue Mar 7, 2016 · 15 comments
Open

Compatibility with big_pipe #258

Berdir opened this issue Mar 7, 2016 · 15 comments
Labels
Milestone

Comments

@Berdir
Copy link
Contributor

Berdir commented Mar 7, 2016

I'm still on 1.x, but I'm having problems with the big_pipe module in 8.1.

Apparently behat/mink/goutte/guzzle doesn't follow the http-equiv refresh metatag that the module ads, and then it doesn't see messages or other "big-piped" blocks.

We should test if 3x still has that problem and possibly explicitly run the tests against 8.1 + big_pipe

@Berdir
Copy link
Contributor Author

Berdir commented Mar 7, 2016

As a possible Workaround, Wim suggested to force the bigpipe no-js cookie for all requests.

@jhedstrom jhedstrom added this to the 3.2.0 release milestone Mar 7, 2016
jhedstrom added a commit that referenced this issue Mar 7, 2016
@jhedstrom
Copy link
Owner

@Berdir so #259 is passing, but that doesn't actually mean this is fixed (we might just not be testing the right things--although there is a test for printed messages). I haven't been able to find any code in Guzzle, or Goutte, or Mink that indicates if http-equiv=refresh is actually used or respected. We might need a fix in the RawDrupalContext, or wherever else might make sense.

@Berdir
Copy link
Contributor Author

Berdir commented Mar 7, 2016

I have tons of tests that assert messages. For example, create a node and then check that the confirmation message is shown. Do you have any of those? They all fail for me.

@jhedstrom
Copy link
Owner

@Berdir I added explicit tests over in #259 for messages, and they are still passing.

@jhedstrom
Copy link
Owner

#259 has been merged, not sure what else can be done here without a way to make the tests fail with big pipe enabled.

@jhedstrom jhedstrom modified the milestones: 3.2.0 release, 4.0 release Jun 16, 2016
@zaporylie
Copy link

BigPipe currently only is enabled for requests with a session.
see https://www.drupal.org/node/2657684

#259 only test messages for anonymous user.

@mglaman
Copy link

mglaman commented Mar 20, 2017

I know this is stale, but I hit this when needing to test local tasks block.

<div data-big-pipe-placeholder-id="callback=Drupal%5Cblock%5CBlockViewBuilder%3A%3AlazyBuilder&amp;args[0]=bartik_local_tasks&amp;args[1]=full&amp;args[2]&amp;token=7daf9ccc"></div><div id="block-bartik-content" class="block block-system block-system-main-block">

But tests fail. On "drupal/drupal-extension": "^3.2" 3.2.2

@mglaman
Copy link

mglaman commented Mar 20, 2017

The PR #259 with the BigPipeContext fixed my problems.

@jhedstrom jhedstrom added the bug label Dec 5, 2017
@normanlolx
Copy link

normanlolx commented Dec 17, 2018

You mean #325? It has the BigPipeContext, which also fixed it for me.

Strange enough I had two similar scenarios, one with a publisher user role, one with an editor user role, both log in, access a random node and should click the "Edit" button. For the publisher this worked, for the editor it doesn't.

Feature: Let's login as users with certain roles and check that node edit
  forms are accessible.

 @api
  Scenario: Login as publisher and try to edit some random node forms
    Given I am logged in as a publisher
    And I visit a random URL # custom step
    And I click "Edit"
    Then I should be redirected to a node form # custom step
    And the response status code should be 200

  @api
  Scenario: Login as editor and try to access some random node forms
    Given I am logged in as an editor
    And I visit a random URL # custom step
    And I click "Edit"
    Then I should be redirected to a node form # custom step
    And the response status code should be 200

This first one always was successful, the second always failed with:

Link with id|title|alt|text "Edit" not found. (Behat\Mink\Exception\ElementNotFoundException)

Finally triggered it down with an HTML screenshot using https://github.com/integratedexperts/behat-screenshot. I searched for the "Edit" string and found it wrapped in some BigPipe related <script> tag. Which after googling for drupal 8 bigpipe local tasks finally brought me here.

@normanlolx
Copy link

And interesting to add, as soon as I used @javascript everything worked fine in a browser. It only happened on the bare @api tagged sessions.

@jhedstrom jhedstrom modified the milestones: 4.0 release, 4.1 release Jul 23, 2019
@AlexSkrypnyk
Copy link

#259 was merged in 2016, but I still do not see the BigPipeContext.php file in the codebase with version 3.4.1.

Had to convert that class into a trait to include intot my FeatureContext.php:

<?php

use Behat\Mink\Exception\UnsupportedDriverActionException;
use Drupal\big_pipe\Render\Placeholder\BigPipeStrategy;

/**
 * Big Pipe trait.
 */
trait BigPipeTrait {

  /**
   * Prepares Big Pipe NOJS cookie if needed.
   *
   * @BeforeScenario
   */
  public function prepareBigPipeNoJsCookie() {
    try {
      // Check if JavaScript can be executed by Driver.
      $this->getSession()->getDriver()->executeScript('true');
    }
    catch (UnsupportedDriverActionException $e) {
      // Set NOJS cookie.
      $this
        ->getSession()
        ->setCookie(BigPipeStrategy::NOJS_COOKIE, TRUE);

    }
    catch (\Exception $e) {
      // Mute exceptions.
    }
  }

}

@vever001
Copy link

vever001 commented Jun 9, 2020

Hello everyone,

I just attempted an update from v4.0.1 to v4.1.0 and I also run into issues with big pipe now.

I tried the BigPipeContext from #325 but this doesn't seem to fix the issue. @Berdir 's comment here might explain why.

The failure happens when it tries to get a task from the Drupal local tasks block.
The HTML is replaced by big_pipe which results in a:
Element matching css ".block-local-tasks-block" not found. (Behat\Mink\Exception\ElementNotFoundException)

Running git bisect, it identified the following commit as the culprit: f0ecbb4

Any idea on what could be causing this from that commit? Before I investigate further.
Thanks,
Hervé

@pfrenssen
Copy link
Collaborator

It doesn't seem likely that this commit is related to the big pipe functionality since it is not involved with retrieving data from the page. Maybe the bisect failed because this commit is depending on a development branch of drupal/drupal-driver that no longer exists.

@vever001
Copy link

I didn't run composer during git bisect.
Commenting those lines causes the issue to disappear.

// Log the user in on the backend if possible.
if ($this->driverManager->getDriver() instanceof AuthenticationDriverInterface) {
  $this->driverManager->getDriver()->login($user);
}

So I guess logging in to the backend causes big_pipe to change behavior and become truly active?

@mglaman
Copy link

mglaman commented Jun 10, 2020

So I guess logging in to the backend causes big_pipe to change behavior and become truly active?

Authenticated users bypass page_cache and BigPipe is then used to deliver dynamic_page_cache items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants