mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #10350 from overleaf/jpa-pdf-caching-debug-context
[web] pdf-caching: more debug context GitOrigin-RevId: ef9b20ef8d9a3b0c6b1b8c200eead1c0f8cf6bde
This commit is contained in:
parent
1c529d5dcf
commit
9e50ab8d1e
2 changed files with 21 additions and 6 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue