Skip to content
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

Update periodic connection check for accuracy #9485

Open
aaemnnosttv opened this issue Oct 9, 2024 · 0 comments
Open

Update periodic connection check for accuracy #9485

aaemnnosttv opened this issue Oct 9, 2024 · 0 comments
Labels
P2 Low priority Type: Infrastructure Engineering infrastructure & tooling

Comments

@aaemnnosttv
Copy link
Collaborator

Feature Description

In #9083 we updated the periodic connection check Site Kit performs which tests for internet connectivity by pinging our REST index endpoint. There is still the potential for inaccurate behavior in the event that the request fails – this happened for me recently when my session timed out and the request failed due to a bad REST nonce. Such a failure is irrelevant to this check though which is only concerned with the request connecting to the backend successfully, rather than authenticating, etc.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • The internet connectivity check should only trigger the offline notification if the backend is unreachable

Implementation Brief

  • Update the fetch made to use fetch rather than apiFetch (adapting as necessary) and remove checks on its response (if the call does not throw, consider online=true, otherwise catch and set false
    try {
    const connectionCheckResponse = await apiFetch( {
    path: '/google-site-kit/v1/',
    } );
    // We are only interested if the request was successful, to
    // confirm online status.
    const canReachConnectionCheck = !! connectionCheckResponse;
    setIsOnline( canReachConnectionCheck );
    } catch ( err ) {
    setIsOnline( false );
    }
  • api-fetch cannot be used because it will throw for any non 200-300 response

Test Coverage

  • Update existing coverage as needed

QA Brief

Changelog entry

@aaemnnosttv aaemnnosttv added P2 Low priority Type: Infrastructure Engineering infrastructure & tooling labels Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Low priority Type: Infrastructure Engineering infrastructure & tooling
Projects
None yet
Development

No branches or pull requests

1 participant