From 60dbcdd08e7c43d428d4ab1d3baabea7366c28ff Mon Sep 17 00:00:00 2001 From: Rebeka Dekany <50901361+rebekadekany@users.noreply.github.com> Date: Tue, 5 Sep 2023 11:25:11 +0200 Subject: [PATCH] Merge pull request #14648 from overleaf/jdt-hist-req-errors swallow abort error on parse fail if specified GitOrigin-RevId: b2c049171e9a0c8bc5869a7ef7498134f8964318 --- services/web/frontend/js/infrastructure/fetch-json.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/web/frontend/js/infrastructure/fetch-json.ts b/services/web/frontend/js/infrastructure/fetch-json.ts index 2ebdf577dc..bfcc0f7f65 100644 --- a/services/web/frontend/js/infrastructure/fetch-json.ts +++ b/services/web/frontend/js/infrastructure/fetch-json.ts @@ -153,6 +153,11 @@ function fetchJSON( } }, error => { + // swallow the error if the fetch was cancelled (e.g. by cancelling an AbortController on component unmount) + if (swallowAbortError && error.name === 'AbortError') { + // the fetch request was aborted while reading/parsing the response body + return + } // parsing the response body failed reject( new FetchError( @@ -168,6 +173,7 @@ function fetchJSON( error => { // swallow the error if the fetch was cancelled (e.g. by cancelling an AbortController on component unmount) if (swallowAbortError && error.name === 'AbortError') { + // the fetch request was aborted before a response was returned return } // the fetch failed