Skip to content

Conversation

@coder-karen
Copy link
Contributor

@coder-karen coder-karen commented Feb 2, 2026

Fixes SYNC-221

Proposed changes:

  • This PR adds a check within do_sync to see if a current request is a cron request. If so, we'll bypass the dedicated sync flow which would otherwise be spawning HTTP requests during cron shutdown, and we now sync directly. This is more reliable, and should reduce lag.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

n/a

Does this pull request change what data or activity we track or use?

No.

Testing instructions:

To test, on a Jetpack self-hosted site that is Jetpack API sandboxed, running the latest trunk or stable release of Jetpack:

  • To test the behaviour and confirm lag times, install WP Crontrol and a snippets plugin like Code Snippets
  • Add the following code snippets to replicate a larger update request for plugin updates: 3a44a-pb .
  • On the WP Crontrol cron events page, location wp_version_check. Click 'edit', and edit the time of the next run to just a few minutes away.
  • After that time has passed, visit the front-end of the site to trigger WP Cron.
  • Check logstash for your site and the event - jetpack_update_plugins_change (using the plugin update snippet) and note down the lag_float time. Do this a few times and record the results. Logstash: bea0fa92853f5aab8a03cab24dfdb9c6-logstash (changing your blog ID).
  • You can test the same for themes - using the following snippet - 3a452-pb - and checking for the jetpack_update_themes_change action lag times.

To test the changes:

  • Apply this PR and follow the same steps. The lag_float should be consistently lower (for example in my case the difference was '2' to '0.2' or thereabouts).
  • You can also confirm that a plugin or theme that actually needs update will be properly updated as well (checking $args in WPcom is correct).

@coder-karen coder-karen self-assigned this Feb 2, 2026
@coder-karen coder-karen added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] In Progress [Package] Sync labels Feb 2, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2026

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the update/sync-do-sync-cron-bypass-dedicated-route branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/sync-do-sync-cron-bypass-dedicated-route
bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/sync-do-sync-cron-bypass-dedicated-route

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2026

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@coder-karen coder-karen marked this pull request as ready for review February 2, 2026 09:32
@coder-karen coder-karen requested a review from a team as a code owner February 2, 2026 09:32
Copilot AI review requested due to automatic review settings February 2, 2026 09:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR modifies the sync behavior to bypass the dedicated sync flow during cron requests, instead syncing directly. The change aims to reduce sync lag for time-sensitive events by avoiding HTTP request spawning during cron shutdown, which can be unreliable.

Changes:

  • Modified do_sync() method to check if the current request is a cron request and bypass dedicated sync if so
  • Added explanatory comment describing the rationale for the cron bypass
  • Added changelog entry documenting the change

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
projects/packages/sync/src/class-sender.php Added cron detection logic to bypass dedicated sync flow and sync directly during cron requests
projects/packages/sync/changelog/update-sync-do-sync-cron-bypass-dedicated-route Added changelog entry documenting the behavior change

Significance: minor
Type: changed

Sync: Ensure we sync directly during cron.
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

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

Remove the "Sync:" prefix from the changelog entry. According to the project's changelog conventions, entries should not use the package name as a prefix when they are within that same package. The entry should simply read "Ensure we sync directly during cron." instead.

Copilot generated this review using guidance from repository custom instructions.
@jp-launch-control
Copy link

Code Coverage Summary

This PR did not change code coverage!

That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷

Full summary · PHP report · JS report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Sync [Status] In Progress [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants