diff --git a/core/core.services.yml b/core/core.services.yml
index fe8d80d..2a82d3e 100644
--- a/core/core.services.yml
+++ b/core/core.services.yml
@@ -283,8 +283,8 @@ services:
     arguments: ['@database', '@lock']
   router.request_context:
     class: Symfony\Component\Routing\RequestContext
-    calls:
-      - [fromRequest, ['@request']]
+    tags:
+      - { name: persist }
   router.admin_context:
     class: Drupal\Core\Routing\AdminContext
     arguments: ['@request_stack']
@@ -458,7 +458,7 @@ services:
     class: Symfony\Component\HttpKernel\EventListener\RouterListener
     tags:
       - { name: event_subscriber }
-    arguments: ['@router']
+    arguments: ['@router', '@router.request_context', NULL, '@request_stack']
   content_negotiation:
     class: Drupal\Core\ContentNegotiation
   view_subscriber:
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
index e19169f..8a82174 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
@@ -1161,6 +1161,12 @@ protected function rebuildContainer($environment = 'testing') {
       $this->container->get('request_stack')->push($request);
     }
     $this->container->get('current_user')->setAccount(\Drupal::currentUser());
+
+    // The request context is normally set by the router_listener from within
+    // its KernelEvents::REQUEST listener. In the simpletest parent site this
+    // event is not fired, therefore it is necessary to updated the request
+    // context manually here.
+    $this->container->get('router.request_context')->fromRequest($request);
   }
 
   /**
