Based on @TheShiftExchange's answer, I was able to track that the route setup caused this behavior. My config/routes.php looks like this:
$route['404_override'] = 'error/index'; $route['(:any)'] = "main/$1";
So, when I made the request www.example.com/nonexistent-url , this request is served by the main controller, then CI noticed that there is no such method that it would execute error/index too, but the main controller was already loaded by then.
Another facebook method was redirected only from the existing main method, for example gallery , so it looks like I went to the URL www.example.com/error/facebook , so the main controller is not loaded because only error/facebook requested . If I call www.example.com/error/index , it works the same, because in this case the main controller does not load, only error .
(The bounty goes to @TheShiftExchange because his answer was the most accurate and provided me with the best information to track the problem. One of my redirects was never reached, which I call the error / index page.)
source share