site-kit-wp icon indicating copy to clipboard operation
site-kit-wp copied to clipboard

PSI API request blocks navigation

Open felixarntz opened this issue 5 years ago • 5 comments

Bug Description

Since the PageSpeed Insights widget in the Site Kit dashboard can take a while for loading its data from the API (sometimes ~10 seconds), this can have a quite annoying UX impact at times.

  1. Ensure the PSI module is activated.
  2. Go to the Site Kit dashboard for the first time in an hour (i.e. all widgets will refresh their data from the APIs).
  3. Immediately (e.g. after 1 or 2 seconds) navigate away to another page (e.g. anywhere else in WP Admin).
  4. Note a significant delay in the navigation - when scrolling down to the PSI widget, you'll see that the widget is still loading, and the navigation finally happens shortly after the PSI data is fully loaded.

I'm not sure exactly why it is happening, but I have been encountering it numerous times, and it is super annoying. I would expect the browser to abort the request in favor of the navigation away, but somehow that doesn't seem to happen - maybe my understanding of how the browser treats those network requests is slightly off.

I'm also not sure whether this really happen every time, but I have been noticing it rather consistently in Chrome for a while. I don't think it's related to any recent change we've introduced, but rather something that we just never flagged as a problem before.


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

Acceptance criteria

  • Navigations away from Site Kit screens in the admin (e.g. the Site Kit dashboard) should not be blocked by slow API requests.
  • It would be best if we can fix this holistically, but if not, at a minimum the slow PageSpeed Insights API requests should no longer block navigations.

Implementation Brief

Test Coverage

Visual Regression Changes

QA Brief

Changelog entry

felixarntz avatar Aug 12 '21 17:08 felixarntz

@fhollis If we have capacity beyond the Idea Hub issues, this one would be great to look into in the next sprint.

felixarntz avatar Aug 12 '21 17:08 felixarntz

Go to the Site Kit dashboard for the first time in an hour Is there any way we can fake this? :thinking:

Otherwise, it's going to be a very long ticket to develop and test :smile:

It would be good if we could add a query string ?force-widgets-refresh-data to reset the timer (similar to with the Idea Hub features we can visit an Url to reset them)

It does sound very odd though! maybe my understanding of how the browser treats those network requests is slightly off - I'm in agreement here. I thought that browsers just did the next request

danielgent avatar Aug 17 '21 12:08 danielgent

@danielgent It can be easily enforced, you need to clear your application data for the site you're testing, specifically the session storage.

felixarntz avatar Aug 17 '21 15:08 felixarntz

@felixarntz I can't seem to reproduce this issue. I've cleared the session storage and am still able to navigate away while the widget is loading. I wonder whether this might be browser-specific or something? 🤔

I did notice this error in the console when the page unloaded though:

Google Site Kit API Error method:GET datapoint:pagespeed type:modules identifier:pagespeed-insights error:"You are probably offline."

johnPhillips avatar Sep 01 '21 11:09 johnPhillips

@johnPhillips Hmm you're right - indeed this might be something specific to my machine or my browser. On my other machine and on my phone things work correctly. Closing this for now.

felixarntz avatar Sep 09 '21 00:09 felixarntz