WordPress / WordPress/Requests

Add documentation about the livecycle of a request

Open
#876 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Type: documentation
Dominant language
PHP
Stars
3.6k
Forks
500
Avg merge
2d 21h
Merged PRs (30d)
5

Description

Hello there 👋👋

I have chosen this issue template since I don't know where else to post my question:

My Question

Are Requests being finished, even if the user that invoked the current script closes their browser?

Additional context

I ended up in this Repo since I source-dived wp-cron to find out how it worked. Turns out it sends a HTTP request from cron.php to wp-cron.php to invoke scheduled jobs:

$result = wp_remote_post( $cron_request['url'], $cron_request['args'] );

That call leads through a few other files to this request call in class-wp-http.php:

$requests_response = WpOrg\Requests\Requests::request( $url, $headers, $data, $type, $options );

Now I couldn't find any resources on the web about the question if this HTTP POST call will be finished, even if the current visitor closes their connection (e.g. browser tab) – or if it will be cancelled with the user session. That would be valuable information for scenarios where there would be long running processes that should be invoked by a cron job.

Source-diving the Requests library also is a bit over my head 😅 I'd be very grateful for any definite answer! It would be amazing to be pointed towards the relevant code, if it turns out that these requests will be finished, not matter what...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading cron.php, wp-cron.php, and the request call in wp-includes/class-wp-http.php, then trace Requests::request in the Requests library. Document the confirmed request lifecycle when the initiating browser connection closes, including relevant code references and guidance for long-running cron jobs.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.