diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php
index 0fda8c8b..c48e7254 100644
--- a/core/modules/views/src/ViewExecutable.php
+++ b/core/modules/views/src/ViewExecutable.php
@@ -2507,7 +2507,7 @@ public function __sleep() {
   public function __wakeup() {
     // There are cases, like in testing where we don't have a container
     // available.
-    if (\Drupal::hasContainer() && !empty($this->serializationData)) {
+    if (\Drupal::hasContainer() && !empty($this->serializationData) && \Drupal::request()) {
       // Load and reference the storage.
       $this->storage = \Drupal::entityTypeManager()->getStorage('view')
         ->load($this->serializationData['storage']);


