From f8035636738a998b4aa26c695f8241b8205b856e Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Tue, 8 Nov 2022 14:40:51 +0000 Subject: [PATCH] Merge pull request #10376 from overleaf/jpa-pdf-caching-disable-first-error [web] pdf-caching: disable pdf-caching after the first non-404 error GitOrigin-RevId: f022e75acd9d5140ae02041b60af9819baa25e62 --- .../js/features/pdf-preview/util/pdf-caching-transport.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/services/web/frontend/js/features/pdf-preview/util/pdf-caching-transport.js b/services/web/frontend/js/features/pdf-preview/util/pdf-caching-transport.js index 6d1a3f3271..a084165473 100644 --- a/services/web/frontend/js/features/pdf-preview/util/pdf-caching-transport.js +++ b/services/web/frontend/js/features/pdf-preview/util/pdf-caching-transport.js @@ -111,6 +111,13 @@ export function generatePdfCachingTransportFactory(PDFJS) { .catch(err => { if (abortSignal.aborted) return if (isExpectedError(err)) { + if (is404(err)) { + // A regular pdf-js request would have seen this 404 as well. + } else { + // Flaky network, switch back to regular pdf-js requests. + metrics.failedCount++ + metrics.failedOnce = true + } throw new PDFJS.MissingPDFException() } metrics.failedCount++