diff --git a/core/lib/Drupal/Core/Routing/RouteProvider.php b/core/lib/Drupal/Core/Routing/RouteProvider.php
index 3dfe65e..a3e0d5a 100644
--- a/core/lib/Drupal/Core/Routing/RouteProvider.php
+++ b/core/lib/Drupal/Core/Routing/RouteProvider.php
@@ -180,6 +180,7 @@ public function getRoutesByNames($names, $parameters = array()) {
 
     $routes_to_load = array_diff($names, array_keys($this->routes));
 
+    $this->routeBuilder->rebuildIfNeeded();
     if ($routes_to_load) {
       $result = $this->connection->query('SELECT name, route FROM {' . $this->connection->escapeTable($this->tableName) . '} WHERE name IN (:names)', array(':names' => $routes_to_load));
       $routes = $result->fetchAllKeyed();
@@ -264,6 +265,7 @@ public function getCandidateOutlines(array $parts) {
    */
   public function getRoutesByPattern($pattern) {
     $path = RouteCompiler::getPatternOutline($pattern);
+    $this->routeBuilder->rebuildIfNeeded();
 
     return $this->getRoutesByPath($path);
   }
