- Issue created by @alexharries
- 🇬🇧United Kingdom jrsouth
Just chipping in because I've just hit what appears to be the same (or very similar) problem after a beta2 to beta3 upgrade. We have redis in our stack too.
All requests coming via the site's default CloudFlare-cached route return the
fromRequest() must be an instance
500 error, but a separate route to the same Drupal instance without CloudFlare caching works as expected.(I imagine it's simply that the non-cached traffic doesn't trigger the module code, and therefore doesn't raise the error, but thought it was worth noting that the site can successfully handle requests with the module active and configured.)
For now I've disabled
cloudflare
andcloudflarepurger
via drush, and the site is working normally via the default route ― though obviously I'd prefer to have those modules enabled!I'm in the very early stages of diagnosing this, will add more as I learn more.
- 🇬🇧United Kingdom jrsouth
For our site this seems to be directly related to "Restore Client IP" setting.
Switching that option off (which is fine for our purposes, even desirable) resulted in a working site via the main route, proxied by Cloudflare.
I'm therefore able to move on from this issue for now, but I'll keep an eye out, and am happy to help diagnose if there are any questions.
- 🇬🇧United Kingdom alexharries
I can confirm this is a problem with "Restore client IP address".
Will update the issue title and description accordingly.
- 🇨🇦Canada brunodbo
I ran into this as well. For anyone else hitting this, you can disable the "Restore Client IP Address" option with
drush config:set cloudflare.settings client_ip_restore_enabled 0
. That made requests cached by Cloudflare work again for me. - 🇺🇸United States Albert Volkman
Seeing this in the 2.0.x branch as well. Bumping up so we can fix it there first.
- 🇺🇸United States Albert Volkman
This looks similar- https://www.drupal.org/project/drupal/issues/3243387 🐛 Argument 1 passed to Drupal\Core\Routing\RequestContext::fromRequest() must be an instance of Symfony\Component\HttpFoundation\Request, null given Closed: cannot reproduce
- 🇮🇪Ireland frankdesign
Just wondering is anyone has figured this one out. I am seeing this issues with Drupal 10.4 and Cloudflare 2.0.0-beta1. As soon as I enable "Restore Client IP Address", the entire site goes down. The only way to resolve is to use Drush to uninstall the module.
- 🇳🇿New Zealand ericgsmith
From what I can see from the original report was at the time 8.x-1.0-beta3
And the line in question was: https://git.drupalcode.org/project/cloudflare/-/blob/8.x-1.0-beta3/src/C...
So for that code to be executed - it looks like the client IP is already the connecting IP provided by cloudflare - so something is already restoring the client ip for you?
Still, that shouldn't blow up the site. The URL doesn't need to be in the log message, probably not appropriate to be doing that in the middleware.
Is anybody able to provide an update stacktrace to verify that it is the same issue?
https://www.drupal.org/project/http_response_headers → could also be used to help debug to see what headers you are getting on the request.
- 🇺🇸United States luke.leber Pennsylvania
I can confirm that some Acquia enterprise environments handle the Client IP restoration as a platform feature.
- 🇳🇿New Zealand RoSk0 Wellington
I suspect and hope that this is now fixed with 🐛 Avoid Translating Logged Messages in Cloudflare Module to Prevent Fatal Error Active , specifically this commit https://git.drupalcode.org/project/cloudflare/-/commit/97cd2c4572a7d4996... (which is confusingly enough tagged with another issue number).
That commit is massive, but you only need to patch
src/CloudFlareMiddleware.php
file to confirm if it is fixed or not.