Call to undefined method RequestStack::getMainRequest()

Created on 12 April 2023, over 1 year ago

Problem/Motivation

Error : Call to undefined method Symfony\Component\HttpFoundation\RequestStack::getMainRequest() dans Drupal\big_pipe_sessionless\Render\BigPipeSessionless->primePageCache() (/home/bas/app_e16ddd73-9120-493c-adf8-9b02a8e7981e/modules/contrib/big_pipe_sessionless/src/Render/BigPipeSessionless.php ligne 118)

It seems it's a regression on 2.1, 2.0 has the right method `getMasterRequest()`

Proposed resolution

replace the code line 118 in BigPipeSessionless.php

<?php
$fake_request = $this->requestStack->getMasterRequest()->duplicate();
?>
🐛 Bug report
Status

Active

Version

2.1

Component

Code

Created by

🇫🇷France Grezag

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

Comments & Activities

  • Issue created by @Grezag
  • First commit to issue fork.
  • @ranjit1032002 opened merge request.
  • 🇮🇳India Ranjit1032002

    Created MR!2 for the issue mentioned, please review.
    Thank You.

  • Status changed to RTBC over 1 year ago
  • 🇮🇳India keshavv India

    Reviewed the code and tested the MR. It looks good, Moving to RTBC.

  • Status changed to Postponed: needs info over 1 year ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    What are the steps to reproduce here?

    Because https://www.drupal.org/project/big_pipe_sessionless/releases/2.1.0 is passing tests on 9.4, 9.5, 10.0 and 10.1: https://www.drupal.org/node/2866448/qa

  • Status changed to Active about 1 year ago
  • 🇩🇪Germany zcht

    Unfortunately I have the same problem, described here 🐛 Undefined method RequestStack::getMasterRequest() Closed: duplicate , the patch from this issue does not help.

  • Status changed to Postponed: needs info about 1 year ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    @Grezag, @Ranjit1032002, @keshavv and @zcht Can you each please let me know which exact version of Drupal core you are using?

    Like I wrote in #6: tests are passing on 9.5, 10.0, 10.1 and even 10.2, since 📌 Adopt GitLab CI Active .

  • 🇩🇪Germany zcht

    I wrote in my first issue: Drupal 10.1.5, PHP 8.1.24, nginx 1.24
    yes, i also saw that the tests ran successfully. unfortunately, the error does occur on the productive environment.

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    I don't yet understand how it could possibly happen that it passes in tests, cannot be reproduced locally on a fresh install, but is happening on your production install.

    The only plausible explanation I can think of right now: somehow, a different version of Symfony is being installed which does not support ::getMainRequest(). Could you please check your composer.lock and composer.json files?

  • 🇩🇪Germany zcht

    Thanks for your feedback, unfortunately I don't understand that either. Thanks for the tip for the symfony version, the composer.lock has the following stored in it:

    "symfony/console":"^6.3",
    "symfony/dependency-injection":"^6.3",
    "symfony/event-dispatcher":"^6.3",
    "symfony/http-foundation":"^6.3",
    "symfony/http-kernel":"^6.3",
    "symfony/mime":"^6.3",
    "symfony/polyfill-iconv":"^1.26",
    "symfony/process":"^6.3",
    "symfony/psr-http-message-bridge":"^2.1",
    "symfony/routing":"^6.3",
    "symfony/serializer":"^6.3",
    "symfony/validator":"^6.3",
    "symfony/yaml":"^6.3",

    When checked on the server itself, all the necessary libraries are included. It can't be Symfony per se, otherwise I wouldn't be able to install Drupal 10.1.x and use various modules and services. It must be something else, but unfortunately I can't explain it at the moment either.

    Just tested again, after I have executed a complete new build via Gitlab CI on the productive environment, I have explicitly set the Sessionless BigPipe module to version 2.2.0. Unfortunately, the same error remains, dblog log contains the errors listed above, the website becomes extremely slow... as soon as the module is deactivated, everything is normal and fast again.

  • Status changed to Needs work 11 months ago
  • 🇩🇪Germany zcht

    Yesterday I updated the entire productive stack, including Drupal to version 10.2.1. I tried again to activate the sessionless BigPipe, as soon as this happens, pretty much all calls on the productive environment break.

    Unfortunately, the error remains, and I cannot reproduce the error locally either.

    A spontaneous idea, I still have the Quicklink module in use, could it be that both modules are interfering with each other? Both modules used to run without problems, but a lot has changed with Drupal and the modules. Perhaps the combination of the two does not fit here. At least that's my only assumption at the moment.

    Full error stack:

    Error: Call to undefined method Symfony\Component\HttpFoundation\RequestStack::getMasterRequest() in Drupal\big_pipe_sessionless\Render\BigPipeSessionless->primePageCache() (Zeile 138 in /var/www/vhosts/docroot/modules/contrib/big_pipe_sessionless/src/Render/BigPipeSessionless.php)
    #0 /var/www/vhosts/docroot/modules/contrib/big_pipe_sessionless/src/Render/BigPipeSessionless.php(85): Drupal\big_pipe_sessionless\Render\BigPipeSessionless->primePageCache()
    #1 /var/www/vhosts/docroot/core/modules/big_pipe/src/Render/BigPipeResponse.php(112): Drupal\big_pipe_sessionless\Render\BigPipeSessionless->sendContent()
    #2 /var/www/vhosts/vendor/symfony/http-foundation/Response.php(425): Drupal\big_pipe\Render\BigPipeResponse->sendContent()
    #3 /var/www/vhosts/docroot/index.php(20): Symfony\Component\HttpFoundation\Response->send()
    #4 {main}
  • Status changed to Postponed: needs info 11 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    How is this possible considering the tests pass just fine? (https://git.drupalcode.org/project/big_pipe_sessionless/-/pipelines/73955)

    Also, how is

    Error: Call to undefined method Symfony\Component\HttpFoundation\RequestStack::getMasterRequest() in Drupal\big_pipe_sessionless\Render\BigPipeSessionless->primePageCache() (Zeile 138 in /var/www/vhosts/docroot/modules/contrib/big_pipe_sessionless/src/Render/BigPipeSessionless.php)
    

    possible given that the code on line 138 is this:

    $fake_request = $this->requestStack->getMainRequest()->duplicate();
    

    👆MAIN, not MASTER 🤯

    What version of big_pipe_sessionless are you on? 🤔

  • 🇩🇪Germany zcht

    I have the current stable version: 2.2.0. The line 138 on the productive environment looks like this, see screenshot. But I also see that it is correct in the source code of the module: https://git.drupalcode.org/project/big_pipe_sessionless/-/blob/2.x/src/R...

    I'm trying to completely uninstall the module, remove it, with between deployments and reinstall it so that the correct code is used. However, I really can't explain why this is the case :(

  • 🇩🇪Germany zcht

    @Wim Leers Thanks again for your support. It was a very wild ride for me, but everything is finally working as it should. Unfortunately I can't explain why it was such a problem with this module in particular. What I did: deactivated and uninstalled the module, deployed to prod, downgraded the module, deployed to prod, deactivated and uninstalled the module, deployed to prod, installed the current version, deployed to prod... everything was fine. really, i have absolutely no idea why this was such a struggle.

    but you are absolutely right, tests are successful, current version runs as it should and i now have the current code version on the productive environment with MAIN, instead of MASTER.

    Thanks again and sorry for the struggle :)

  • Status changed to Fixed 2 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Marking as fixed per #15. I think you hit a weird "wrong Symfony or BigPipe Sessionless version installed" problem, see #3428235-11: New major release for Drupal 11 compatibility .

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024