exclude loopback requests from trying to pre-fetch#3305
Draft
exclude loopback requests from trying to pre-fetch#3305
Conversation
adamziel
reviewed
Feb 25, 2026
| $parsed = parse_url($url); | ||
| $host = isset($parsed['host']) ? $parsed['host'] : ''; | ||
| if ($host === 'localhost' || $host === '127.0.0.1' || $host === '::1' || $host === '[::1]') { | ||
| return new WP_Error( 'http_request_block', 'Loopback requests are not pre-fetched' ); |
Collaborator
There was a problem hiding this comment.
Did we confirm the requests to api.w.org are still pre-fetched with this change?
Member
Author
There was a problem hiding this comment.
Yes, we still pre-fetch those 5 requests. I am yet to verify that cron loopback request was getting caught in this filter. Opus seems to think that was the case based on console logs, but once I verify that, I will mark this PR as ready for review :)
Member
Author
There was a problem hiding this comment.
Finally confirmed this could happen so we should prevent this. Improved the code. You can review but please don't merge yet.
b03da06 to
d72ffb8
Compare
d72ffb8 to
bb1f6e6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation for the change, related issues
Under special cron conditions (WordPress plugin that wants to be aggressive about triggering cron), loopback url was caught inside of pre-filter check, which would compete for an existing php worker instance, making the user initiated request wait up, leading to poor experience.
This PR prevents that loopback call from happening.
Implementation details
Testing Instructions (or ideally a Blueprint)