Problem/Motivation
We're seeing the exception AssertionError: assert(is_string($chunk) || $chunk instanceof HtmlResponse) in assert() (line 259 of /var/www/html/web/core/modules/big_pipe/src/Render/BigPipe.php)
with the following stack trace:
#0 /var/www/html/web/core/modules/big_pipe/src/Render/BigPipe.php(259): assert()
#1 /var/www/html/web/core/modules/big_pipe/src/Render/BigPipe.php(369): Drupal\big_pipe\Render\BigPipe->sendChunk()
#2 /var/www/html/web/core/modules/big_pipe/src/Render/BigPipe.php(304): Drupal\big_pipe\Render\BigPipe->sendPreBody()
#3 /var/www/html/web/core/modules/big_pipe/src/Render/BigPipeResponse.php(112): Drupal\big_pipe\Render\BigPipe->sendContent()
#4 /var/www/html/vendor/symfony/http-foundation/Response.php(381): Drupal\big_pipe\Render\BigPipeResponse->sendContent()
#5 /var/www/html/web/index.php(20): Symfony\Component\HttpFoundation\Response->send()
#6 {main}
This is caused by
[$pre_scripts_bottom, $scripts_bottom, $post_scripts_bottom] = explode('<drupal-big-pipe-scripts-bottom-marker>', $pre_body, 3);
// ...
$this->sendChunk($scripts_bottom);
in \Drupal\big_pipe\Render\BigPipe::sendPreBody
where obviously the separator used by explode
isn't present in the pre body string and hence, $scripts_bottom
is NULL.
This is confirmed because of 2 warnings prior to the exception that tell us Warning: Undefined array key 1
and Warning: Undefined array key 2
.
Steps to reproduce
I can't reproduce but I found out the context what must have happened: an unpublished node gets requested by an IP which comes from MailChimp. I suspect, that somebody at the customer site is preparing a newsletter and wants to refer to a node which is present but not published yet. And then, the MailChimp platform seems to undertake some fancy requests that lead to such exceptions.
Proposed resolution
Before calling for explode
, we should test if <drupal-big-pipe-scripts-bottom-marker>
is contained in the string and if not, just return without doing anything.