Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 298686

Ensure good UX & DX even when A) rendering of placeholder fails, B) some response event subscriber fails

$
0
0

Problem/Motivation

In the BigPipe D8.1 core issue, @dawehner said this at #2469431-212: BigPipe for auth users: first send+render the cheap parts of the page, then the expensive parts:

+++ b/core/modules/big_pipe/src/Render/BigPipe.php
@@ -0,0 +1,432 @@
+      $fake_request = $this->requestStack->getMasterRequest()->duplicate();
+      $this->requestStack->push($fake_request);
+      $event = new FilterResponseEvent($this->httpKernel, $fake_request, HttpKernelInterface::SUB_REQUEST, $html_response);
+      $this->eventDispatcher->dispatch(KernelEvents::RESPONSE, $event);
+      $this->requestStack->pop();

I'm wondering whether we need to try catch here and reset the request stack in case some exceptions are thrown inside.

The obvious conclusion to jump to after reading that is: when something goes wrong when rendering placeholders, things will break badly. But that's actually not what that code does, it doesn't render placeholders. That happens earlier! So we should also wrap the code responsible for doing that in a try…catch.

The code that @dawehner quotes actually can only be broken if some response event subscriber throws an exception. This of course should also be tested.

Broken logic to render a placeholder is probably 100 times more common than a broken response event subscriber. So, let's also address that here too.

Proposed resolution

Broken logic to render a placeholder
  1. Add test case that explicitly throws an exception while rendering the placeholder.
  2. Verify that in production (non-verbose error logging), the exception is caught and not shown to the end user, that placeholder is then simply not shown
  3. Verify that in development (verbose error logging), the exception is not caught and shown to the end user, to not get in the way of the developer doing debugging
Broken response event subscriber
Same, but for an exception thrown in a response event subscriber, not while rendering a placeholder.

Remaining tasks

  1. Handle broken placeholder rendering
  2. Handle broken response event subscriber
  3. Reviews
  4. Commit

User interface changes

When

API changes

None.

Data model changes

None.


Viewing all articles
Browse latest Browse all 298686


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>