Skip to content

Newsletter: fix editor email stats timeout flashing errors (NL-578)#48002

Merged
jeherve merged 1 commit intotrunkfrom
fix/editor-email-stats-timeout-flash
Apr 10, 2026
Merged

Newsletter: fix editor email stats timeout flashing errors (NL-578)#48002
jeherve merged 1 commit intotrunkfrom
fix/editor-email-stats-timeout-flash

Conversation

@allilevine
Copy link
Copy Markdown
Member

@allilevine allilevine commented Apr 8, 2026

Fixes NL-578

Proposed changes

  • getTotalEmailsSentCount resolver now fails silently on error instead of dispatching a snackbar notice + flipping api state to disconnected. Email open rate is purely informational and should never surface as an editor error. Errors are logged to console.warn for debuggability.
  • The Newsletter panel (subscribers-affirmation.js) now only triggers the email-open-rate fetch when status === 'publish'. Drafts, auto-drafts, pending, and scheduled posts have never been emailed, so the request would be a guaranteed miss (and contributed to the timeouts reported in the ticket).
  • Extended resolvers-test.js with coverage for the rejected-promise (timeout) path and to assert the WP_Error path no longer calls onError/dispatches.
Error Pre-publish Post-publish email stats
Screenshot 2026-04-08 at 1 50 32 PM Screenshot 2026-04-08 at 2 08 12 PM Screenshot 2026-04-08 at 1 59 23 PM

Other information

The WPCOM stats/opens/emails/{post}/rate endpoint has a hard-coded 5s timeout on the client. On large sites (e.g. seths.blog, 147199084) the request regularly exceeds that, flashing cURL error 28 in Gutenberg on every editor load.

The ticket also mentions /stats/emails/summary timing out on the Jetpack Stats dashboard Newsletter tab. That lives in the stats-admin package and is a separate surface — not fixed here; happy to open a follow-up.

Related product discussion/links

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

No.

Testing instructions

Unit tests

  • pnpm jest extensions/store/membership-products/test/resolvers-test.js — 9/9 passing
  • pnpm jest extensions/shared/memberships/test/subscribers-affirmation-test.js — 39/39 passing

Manual — error no longer flashes

  1. On a site with Jetpack Newsletter enabled, drop this file at wp-content/mu-plugins/force-stats-timeout.php to force the timeout:
    <?php
    add_filter( 'pre_http_request', function( $preempt, $args, $url ) {
        if ( strpos( $url, 'stats/opens/emails' ) !== false ) {
            return new WP_Error( 'http_request_failed',
                'cURL error 28: Operation timed out after 5000 milliseconds with 0 bytes received' );
        }
        return $preempt;
    }, 10, 3 );
  2. Open any published post in the block editor.
  3. Expected: no snackbar error. Before this patch, a "cURL error 28" snackbar flashed in the corner.

Manual — no fetch on drafts

  1. Create a brand new post in the block editor.
  2. Open devtools → Network, filter to stats/opens/emails.
  3. Expected: no request fires. The Newsletter panel still renders the pre-publish affirmation copy.

Manual — still works on published posts

  1. Open a previously-sent published post that has email open stats.
  2. Expected: the panel still loads email stats copy as it did before.

To test on Simple, sandbox the Simple site and public api.

🤖 Generated with Claude Code

… drafts

The Newsletter panel's getTotalEmailsSentCount resolver has a hard 5s timeout.
On large sites the WPCOM stats/opens/emails endpoint can exceed that, and the
resolver surfaced the error as a snackbar in the editor — flashing "cURL error
28" on every load. It also fired for brand new drafts that had never been sent.

- Fail silently on fetch errors; open rate is informational and should never
  flip api state or raise an editor notice. Log to console.warn instead.
- Only trigger the fetch for already-published posts (status === 'publish').
- Extend resolver tests to cover timeout/reject and WP_Error paths.

Fixes NL-578.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@allilevine allilevine self-assigned this Apr 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 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), and enable the fix/editor-email-stats-timeout-flash branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/editor-email-stats-timeout-flash

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 github-actions bot added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests labels Apr 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 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!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: May 5, 2026
    • Code freeze: May 4, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Apr 8, 2026
@jp-launch-control
Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/extensions/store/membership-products/resolvers.js 87/130 (66.92%) -0.25% 0 💚

Full summary · PHP report · JS report

@allilevine allilevine requested a review from a team April 8, 2026 18:10
@jeherve jeherve added Bug When a feature is broken and / or not performing as intended [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Apr 9, 2026
@jeherve jeherve merged commit 76e2f64 into trunk Apr 10, 2026
78 of 79 checks passed
@jeherve jeherve deleted the fix/editor-email-stats-timeout-flash branch April 10, 2026 07:56
@github-actions github-actions bot added this to the jetpack/15.8 milestone Apr 10, 2026
@github-actions github-actions bot removed the [Status] Ready to Merge Go ahead, you can push that green button! label Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug When a feature is broken and / or not performing as intended [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants