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 b7988ed84e..6d1a3f3271 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 @@ -120,7 +120,12 @@ export function generatePdfCachingTransportFactory(PDFJS) { } err = OError.tag(err, 'optimized pdf download error', getDebugInfo()) console.error(err) - captureException(err, { tags: { fromPdfCaching: true } }) + captureException(err, { + tags: { + fromPdfCaching: true, + isFromOutputPDFRequest: isFromOutputPDFRequest(err), + }, + }) return fallbackRequest({ url: this.url, start, @@ -142,7 +147,12 @@ export function generatePdfCachingTransportFactory(PDFJS) { err = OError.tag(err, 'fatal pdf download error', getDebugInfo()) console.error(err) if (!(err instanceof PDFJS.MissingPDFException)) { - captureException(err, { tags: { fromPdfCaching: true } }) + captureException(err, { + tags: { + fromPdfCaching: true, + isFromOutputPDFRequest: isFromOutputPDFRequest(err), + }, + }) } // Signal error for (subsequent) page load. this.handleFetchError(err) diff --git a/services/web/frontend/js/features/pdf-preview/util/pdf-caching.js b/services/web/frontend/js/features/pdf-preview/util/pdf-caching.js index 63af47789b..b0216a8ab8 100644 --- a/services/web/frontend/js/features/pdf-preview/util/pdf-caching.js +++ b/services/web/frontend/js/features/pdf-preview/util/pdf-caching.js @@ -440,7 +440,10 @@ function resolveMultiPartResponses({ file, chunks, data, boundary, metrics }) { */ function checkChunkResponse(response, estimatedSize, init) { if (!(response.status === 206 || response.status === 200)) { - throw new OError('non successful response status: ' + response.status) + throw new OError('non successful response status: ' + response.status, { + responseHeaders: Object.fromEntries(response.headers.entries()), + requestHeader: init.headers, + }) } const responseSize = getResponseSize(response) if (!responseSize) { @@ -541,6 +544,10 @@ async function fetchChunk({ metrics, cachedUrlLookupEnabled, }) { + const estimatedSize = Array.isArray(chunk) + ? estimateSizeOfMultipartResponse(chunk) + : chunk.end - chunk.start + const oldUrl = cachedUrls.get(chunk.hash) if (cachedUrlLookupEnabled && chunk.hash && oldUrl && oldUrl !== url) { // When the clsi server id changes, the content id changes too and as a @@ -549,6 +556,7 @@ async function fetchChunk({ try { const response = await fetch(oldUrl, init) if (response.status === 200) { + checkChunkResponse(response, estimatedSize, init) metrics.oldUrlHitCount += 1 return response } @@ -562,9 +570,6 @@ async function fetchChunk({ } } const response = await fetch(url, init) - const estimatedSize = Array.isArray(chunk) - ? estimateSizeOfMultipartResponse(chunk) - : chunk.end - chunk.start checkChunkResponse(response, estimatedSize, init) if (chunk.hash) cachedUrls.set(chunk.hash, url) return response