src/Render/BigPipe.php | 25 +++++++++++--
src/Tests/BigPipePlaceholderTestCases.php | 41 +++++++++++++++++++++
src/Tests/BigPipeTest.php | 8 +++++
.../big_pipe_test/src/BigPipeTestController.php | 15 ++++++++
.../src/EventSubscriber/BigPipeTestSubscriber.php | 42 ++++++++++++++++++++--
.../Render/Placeholder/BigPipeStrategyTest.php | 3 ++
6 files changed, 129 insertions(+), 5 deletions(-)
diff --git a/src/Render/BigPipe.php b/src/Render/BigPipe.php
index bf002ee..8e4b953 100644
--- a/src/Render/BigPipe.php
+++ b/src/Render/BigPipe.php
@@ -266,7 +266,18 @@ class BigPipe implements BigPipeInterface {
// - the HTML to load the JS (at the top) can be rendered.
$fake_request = $this->requestStack->getMasterRequest()->duplicate();
$fake_request->request->set('ajax_page_state', ['libraries' => implode(',', $cumulative_assets->getAlreadyLoadedLibraries())]);
- $html_response = $this->filterEmbeddedResponse($fake_request, $html_response);
+ try {
+ $html_response = $this->filterEmbeddedResponse($fake_request, $html_response);
+ }
+ catch (\Exception $e) {
+ if (\Drupal::config('system.logging')->get('error_level') === ERROR_REPORTING_DISPLAY_VERBOSE) {
+ throw $e;
+ }
+ else {
+ continue;
+ }
+ }
+
// Send this embedded HTML response.
print $html_response->getContent();
@@ -360,7 +371,17 @@ class BigPipe implements BigPipeInterface {
// allows us to track the total set of asset libraries sent in the
// initial HTML response plus all embedded AJAX responses sent so far.
$fake_request->request->set('ajax_page_state', ['libraries' => implode(',', $cumulative_assets->getAlreadyLoadedLibraries())] + $cumulative_assets->getSettings()['ajaxPageState']);
- $ajax_response = $this->filterEmbeddedResponse($fake_request, $ajax_response);
+ try {
+ $ajax_response = $this->filterEmbeddedResponse($fake_request, $ajax_response);
+ }
+ catch (\Exception $e) {
+ if (\Drupal::config('system.logging')->get('error_level') === ERROR_REPORTING_DISPLAY_VERBOSE) {
+ throw $e;
+ }
+ else {
+ continue;
+ }
+ }
// Send this embedded AJAX response.
$json = $ajax_response->getContent();
diff --git a/src/Tests/BigPipePlaceholderTestCases.php b/src/Tests/BigPipePlaceholderTestCases.php
index 3fd503c..e7bed06 100644
--- a/src/Tests/BigPipePlaceholderTestCases.php
+++ b/src/Tests/BigPipePlaceholderTestCases.php
@@ -300,6 +300,46 @@ class BigPipePlaceholderTestCases {
];
$exception->embeddedHtmlResponse = NULL;
+ // 7. Exception: placeholder that causes response filter to throw exception.
+ $embedded_response_exception = new BigPipePlaceholderTestCase(
+ [
+ '#lazy_builder' => ['\Drupal\big_pipe_test\BigPipeTestController::responseException', []],
+ '#create_placeholder' => TRUE,
+ ],
+ '