Skip to content

Connection: adapt js component for custom errors #44281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: trunk
Choose a base branch
from

Conversation

bindlegirl
Copy link
Contributor

@bindlegirl bindlegirl commented Jul 11, 2025

Previously in #43593 we added support for Protected owner errors, but due to how the Error Handler was built, we hardcoded the error type into PHP and js files.

This PR is continuing the work started in #44042 where we refactored the PHP side of connection error handling so nothing has to be hardcoded. Now we are removing the protected owner errors from js files and adding support for dynamically added custom errors.

Errors are added to PHP via filter (currently limited to WoA sites), and they contain data used by JS to build error notification and actions ( message text, action type, tracking code). The Error Handler class now includes a helper function to construct a valid error_data array.

Additionally, PHP and JS can now handle custom errors with two action buttons. The secondary button is optional, but we already know we will need it for WoA pghT6q-6h-p2#comment-34.

Default connection errors should work as usual.

Closes VULCAN-184

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

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

Testing instructions:

  • Create a JN site and connect Jetpack.
  • Use the Beta plugin to load this PR.
  • Use the Debug tool plugin to generate a connection error. Check My Jetpack and main dashboard to confirm they show up as usual, and the Reconnect button works.
  • To test custom errors, it's best to fully replace the Error Handler PHP file (class-error-handler.php) in the connection package with code from this link: 38618-pb/ The test file disbles protections that prevent custom errors on nonWoA sites and adds temp test array via filter that will otherwise get used in wpcomsh.
  • Edit the custom options in temp_add_protected_owner_error() to display one or two buttons and edit other parameters.
  • Make sure errors show up on the dashboard, My Jetpack, and a standalone plugin page like Social.
  • Alternative: test this PR together with Connection: update protected owner class #44284.

Copy link
Contributor

github-actions bot commented Jul 11, 2025

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/connection-error-refactor-js branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/connection-error-refactor-js
bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/connection-error-refactor-js

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 [JS Package] Connection [Package] Connection [Package] My Jetpack [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Tests] Includes Tests Admin Page React-powered dashboard under the Jetpack menu RNA labels Jul 11, 2025
Copy link
Contributor

github-actions bot commented Jul 11, 2025

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 a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ 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: August 5, 2025
    • Code freeze: August 4, 2025

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 Jul 11, 2025
Copy link

jp-launch-control bot commented Jul 11, 2025

Code Coverage Summary

Coverage changed in 7 files. Only the first 5 are listed here.

File Coverage Δ% Δ Uncovered
projects/js-packages/connection/hooks/use-connection-error-notice/index.jsx 0/66 (0.00%) -25.00% 39 💔
projects/js-packages/connection/hooks/use-restore-connection/index.jsx 0/23 (0.00%) -4.35% 1 ❤️‍🩹
projects/plugins/jetpack/_inc/client/components/notice/notice-action.jsx 9/10 (90.00%) -10.00% 1 ❤️‍🩹
projects/packages/my-jetpack/_inc/hooks/use-notification-watcher/use-connection-errors-notice.tsx 49/50 (98.00%) 1.70% 0 💚
projects/plugins/jetpack/_inc/client/components/jetpack-notices/jetpack-connection-errors.jsx 2/20 (10.00%) 0.48% -1 💚

Full summary · PHP report · JS report

If appropriate, add one of these labels to override the failing coverage check: Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage.

@bindlegirl bindlegirl added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code 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 Jul 11, 2025
@bindlegirl bindlegirl marked this pull request as ready for review July 11, 2025 12:44
@bindlegirl bindlegirl self-assigned this Jul 11, 2025
@bindlegirl bindlegirl requested review from sergeymitr and a team July 11, 2025 12:45
@bindlegirl bindlegirl added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Jul 11, 2025
@bindlegirl bindlegirl removed the Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code label Jul 11, 2025
sergeymitr
sergeymitr previously approved these changes Jul 14, 2025
Copy link
Contributor

@sergeymitr sergeymitr left a comment

Choose a reason for hiding this comment

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

Works well, as far as I can tell. Just a couple of suggestions, otherwise good to go 👍

@sergeymitr sergeymitr added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Jul 14, 2025
@bindlegirl
Copy link
Contributor Author

Thank you for reviewing this and for your suggestions @sergeymitr ! I made changes to address both recommendations.

Copy link
Contributor

@sergeymitr sergeymitr left a comment

Choose a reason for hiding this comment

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

Works great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Admin Page React-powered dashboard under the Jetpack menu [JS Package] Components [JS Package] Connection [Package] Connection [Package] My Jetpack [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ RNA [Status] Ready to Merge Go ahead, you can push that green button! [Tests] Includes Tests [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