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
- Add test case that explicitly throws an exception while rendering the placeholder.
- 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
- 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
Handle broken placeholder renderingHandle broken response event subscriber- Reviews
- Commit
User interface changes
When
API changes
None.
Data model changes
None.