Skip to content

Suppress network errors in Apollo during navigation

What does this MR do and why?

This MR adds an ApolloLink to our GraphQL client side stack which suppresses errors due to cancelled requests due to navigation. This is very similar in concept to !16545 (merged), except for Apollo rather than axios.


In #335530 (closed) it's noted that Sentry logs a lot of unhandled network errors, mostly involving the graphql webpack chunk.

The main reason we're seeing these is that we have various places in the codebase where request errors are not handled, or are rethrown and then not handled).

Genuine network errors can't really be fixed, besides retrying them or just ignoring them. But, network errors due to cancelled requests during navigation can be handled a bit better. As described in #335530 (comment 699517137), Chrome behaves a bit differently to Firefox in when it cancels in-flight requests. This MR reduces the inconsistency between them by pretending that these errors never happened, and letting the request hang (until the current page is torn down, anyway).

This is very similar to !16545 (merged), except for Apollo rather than axios.

Screenshots or screen recordings

Before (master and this branch with feature flag disabled) After (feature flag enabled)
before after

How to set up and validate locally

Observing current (buggy) behaviour

This can be done either on this MR's branch or master.

  1. Apply this patch to make getPaginatedTree query artificially slow. This makes the original problem much easier to reproduce.
  2. Visit any project's Repository -> Files page in Firefox, and open the browser console.
  3. While the project's files view is in the skeleton loading state, click on any link to navigate to another page.
  4. Observe that an error alert appears at the top of the page before the new page loads.
  5. Observe that a network error is logged to the console.

If you perform the same steps with Chrome, steps 4 and 5 probably won't happen, for reasons described in #335530 (comment 699517137).

Observing the fixed behaviour

  1. Enable the suppress_apollo_errors_during_navigation feature flag.
  2. Apply this patch to make getPaginatedTree query artificially slow. This makes the original problem much easier to reproduce.
  3. Visit any project's Repository -> Files page in Firefox, and open the browser console.
  4. While the project's files view is in the skeleton loading state, click on any link to navigate to another page.
  5. You should not see an error alert appears at the top of the page before the new page loads!
  6. You should not see a network error is logged to the console!

Feature flag

Behind suppress_apollo_errors_during_navigation. See #342745 (closed) for rollout.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #335530 (closed)

Edited by Mark Florian

Merge request reports