Skip to content

exclude loopback requests from trying to pre-fetch#3305

Draft
ashfame wants to merge 1 commit intotrunkfrom
prevent_loopback_from_prefetch_logic
Draft

exclude loopback requests from trying to pre-fetch#3305
ashfame wants to merge 1 commit intotrunkfrom
prevent_loopback_from_prefetch_logic

Conversation

@ashfame
Copy link
Member

@ashfame ashfame commented Feb 25, 2026

⚠️ DO NOT MERGE YET

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)

$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' );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we confirm the requests to api.w.org are still pre-fetched with this change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally confirmed this could happen so we should prevent this. Improved the code. You can review but please don't merge yet.

@ashfame ashfame force-pushed the prevent_loopback_from_prefetch_logic branch 2 times, most recently from b03da06 to d72ffb8 Compare February 26, 2026 20:54
@ashfame ashfame force-pushed the prevent_loopback_from_prefetch_logic branch from d72ffb8 to bb1f6e6 Compare February 26, 2026 21:03
@ashfame ashfame self-assigned this Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants