Commit 09dd832f authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'nfriend-remove-suppress-ajax-navigation-errors-' into 'master'

Remove `suppress_ajax_navigation_errors` feature flag

Closes #32268

See merge request gitlab-org/gitlab!21772
parents dcfbfb8c 3686f62f
......@@ -33,11 +33,9 @@ window.addEventListener('beforeunload', () => {
// Ignore AJAX errors caused by requests
// being cancelled due to browser navigation
const { gon } = window;
const featureFlagEnabled = gon && gon.features && gon.features.suppressAjaxNavigationErrors;
axios.interceptors.response.use(
response => response,
err => suppressAjaxErrorsDuringNavigation(err, isUserNavigating, featureFlagEnabled),
err => suppressAjaxErrorsDuringNavigation(err, isUserNavigating),
);
export default axios;
......
......@@ -2,8 +2,8 @@
* An Axios error interceptor that suppresses AJAX errors caused
* by the request being cancelled when the user navigates to a new page
*/
export default (err, isUserNavigating, featureFlagEnabled) => {
if (featureFlagEnabled && isUserNavigating && err.code === 'ECONNABORTED') {
export default (err, isUserNavigating) => {
if (isUserNavigating && err.code === 'ECONNABORTED') {
// If the user is navigating away from the current page,
// prevent .then() and .catch() handlers from being
// called by returning a Promise that never resolves
......
......@@ -41,7 +41,6 @@ module Gitlab
# Initialize gon.features with any flags that should be
# made globally available to the frontend
push_frontend_feature_flag(:suppress_ajax_navigation_errors, default_enabled: true)
push_frontend_feature_flag(:snippets_vue, default_enabled: false)
end
......
......@@ -6,24 +6,20 @@ describe('suppressAjaxErrorsDuringNavigation', () => {
const NAV_ERR_CODE = 'ECONNABORTED';
it.each`
isFeatureFlagEnabled | isUserNavigating | code
${false} | ${false} | ${OTHER_ERR_CODE}
${false} | ${false} | ${NAV_ERR_CODE}
${false} | ${true} | ${OTHER_ERR_CODE}
${false} | ${true} | ${NAV_ERR_CODE}
${true} | ${false} | ${OTHER_ERR_CODE}
${true} | ${false} | ${NAV_ERR_CODE}
${true} | ${true} | ${OTHER_ERR_CODE}
`('should return a rejected Promise', ({ isFeatureFlagEnabled, isUserNavigating, code }) => {
isUserNavigating | code
${false} | ${OTHER_ERR_CODE}
${false} | ${NAV_ERR_CODE}
${true} | ${OTHER_ERR_CODE}
`('should return a rejected Promise', ({ isUserNavigating, code }) => {
const err = { code };
const actual = suppressAjaxErrorsDuringNavigation(err, isUserNavigating, isFeatureFlagEnabled);
const actual = suppressAjaxErrorsDuringNavigation(err, isUserNavigating);
return expect(actual).rejects.toBe(err);
});
it('should return a Promise that never resolves', () => {
const err = { code: NAV_ERR_CODE };
const actual = suppressAjaxErrorsDuringNavigation(err, true, true);
const actual = suppressAjaxErrorsDuringNavigation(err, true);
const thenCallback = jest.fn();
const catchCallback = jest.fn();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment