Opened 5 months ago
Last modified 5 months ago
#62223 new defect (bug)
"Error in moving the item to Trash" when using Cloudflare Speed Brain (Missing/Unreachable directories)
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Posts, Post Types | Keywords: | |
Focuses: | Cc: |
Description
Cloudflare has implemented a "Speed Brain" feature which uses the Speculation-Rules API to make prefetch requests. It was launched on September 25, 2024.
All Cloudflare free accounts are opted into this feature by default. However during the beta period not all requests have the feature enabled.
To confirm that "Speed Brain" is active on the request: "check that your HTTP response headers for your web pages include the Speculation-Rules header." Approximately 25% to 50% of requests were observed to have this header.
Only Chromium browsers have implemented this experimental feature: https://caniuse.com/mdn-http_headers_speculation-rules
Speed Brain is designed to not hit the origin server:
"Prefetch requests will never reach origin servers. Prefetch requests only serve content that is stored in Cloudflare’s Cache. If the content is not in Cache, the prefetch request will not continue to origin servers. Without this safeguard, origin server state could be modified despite the prefetch response not being rendered in the browser. An example of this could be a prefetch GET request to a sign-out URL inadvertently triggering a sign-out action on the server." https://developers.cloudflare.com/speed/optimization/content/speed-brain/
Errors Observed
With Speed Brain enabled status 503 errors are generated when creating a new post.
Although this is generating 503 errors, it does not appear that the 503 requests hit the origin server.
When deleting a post, 503 errors are generated and the error message "Error in moving the item to Trash" is displayed.
This 500 does seem to hit the origin server:
162.158.63.78 - example.com - [14/Oct/2024:22:25:01 +0000] "GET /wp-admin/post.php?post=163&action=trash&_wpnonce=8076b7b729 HTTP/1.1" 302 - "https://www.example.com/wp-admin/edit.php?post_type=post" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36" 162.158.63.78 - example.com - [14/Oct/2024:22:25:02 +0000] "GET /wp-admin/post.php?post=163&action=trash&_wpnonce=8076b7b729 HTTP/1.1" 500 2484 "https://www.example.com/wp-admin/edit.php?post_type=post" "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Mobile Safari/537.36"
No errors or warnings are logged by this delete.
Steps to Reproduce
- Ensure that Cloudflare Speed Brain is enabled on your domain: Go to Speed > Optimization > Content Optimization.
- Visit WordPress Posts page
- Ensure that Speed Brain is active on your requests by request by refreshing page and checking for the "speculation-rules" header on the document (value of "/cdn-cgi/speculation" when testing)
- Create a new post using the block editor, note 503 errors
- Publish post, return to Posts page
- Confirm "speculation-rules" header exists on request
- Trash post
- "Error in moving the item to Trash." message displayed
- Post was successfully deleted on refresh of Posts page
With Speed Brain disabled, no 503 errors or "Error in moving the item to Trash" message appears.
Tested on PHP 8.0.30 with WordPress 6.6.2.
Expected Behavior
No 503 errors when visiting Post editor or trashing the post.
Actual Behavior
When creating the Post initially, the 503 prefetch has this header:
Status Code: 503 Service Unavailable (from prefetch cache) cf-speculation-refused: prefetch refused: not eligible
When trashing the post, it appears that Cloudflare is sending both GET requests to the origin server, despite:
Status Code: 503 Service Unavailable (from prefetch cache) cf-speculation-refused: prefetch refused: not eligible
This issue with Cloudflare Speed Brain potentially exacerbated issues with ticket:61114.