Просмотр исходного кода

Merge pull request #14648 from overleaf/jdt-hist-req-errors

swallow abort error on parse fail if specified

GitOrigin-RevId: b2c049171e9a0c8bc5869a7ef7498134f8964318
Rebeka Dekany 3 лет назад
Родитель
Сommit
60dbcdd08e
1 измененных файлов с 6 добавлено и 0 удалено
  1. 6 0
      services/web/frontend/js/infrastructure/fetch-json.ts

+ 6 - 0
services/web/frontend/js/infrastructure/fetch-json.ts

@@ -153,6 +153,11 @@ function fetchJSON<T>(
             }
           },
           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<T>(
       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