Updated: Comment #N
Problem/Motivation
When some code needs to rebuild the router, it calls setRebuildNeeded() instead of calling rebuild() directly, in order to prevent multiple rebuilds in one request.
RouterRebuildSubscriber subscribes to KernelEvents::TERMINATE to check if it was set to rebuild, and it runs then.
However, in the case of a rebuild triggered right before a redirect, the redirect will happen *before* the router even starts rebuilding, and the route rebuilding only gets about 30% done before the next request starts.
In the case of #2229303: Enable/add of search pages leads to route not found exception, the redirected page tries to use a route that has not been built yet, and it fatals.
Proposed resolution
N/A
Remaining tasks
Find some way to fix this.
User interface changes
N/A
API changes
N/A