mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-17 10:38:47 +00:00
Merge pull request #9010 from overleaf/jpa-ignore-404
[web] do not consider a 404 on the main pdf url as pdf caching failure GitOrigin-RevId: 2d57ee92b79227baa58f2e71edbcf63a4848435d
This commit is contained in:
parent
b795579ca0
commit
6485731c98
2 changed files with 22 additions and 7 deletions
|
@ -59,6 +59,15 @@ export function generatePdfCachingTransportFactory(PDFJS) {
|
|||
abortSignal,
|
||||
})
|
||||
.catch(err => {
|
||||
if (
|
||||
err.message === 'non successful response status: 404' &&
|
||||
OError.getFullInfo(err).url === this.url
|
||||
) {
|
||||
// Do not consider a 404 on the main pdf url as pdf caching failure.
|
||||
// Still, bail out during the initial launch phase.
|
||||
failedOnce = true
|
||||
throw new PDFJS.MissingPDFException()
|
||||
}
|
||||
metrics.failedCount++
|
||||
failedOnce = true
|
||||
if (!enablePdfCaching) {
|
||||
|
@ -75,7 +84,9 @@ export function generatePdfCachingTransportFactory(PDFJS) {
|
|||
.catch(err => {
|
||||
err = OError.tag(err, 'fatal pdf download error', errorInfo)
|
||||
console.error(err)
|
||||
captureException(err, { tags: { fromPdfCaching: true } })
|
||||
if (!(err instanceof PDFJS.MissingPDFException)) {
|
||||
captureException(err, { tags: { fromPdfCaching: true } })
|
||||
}
|
||||
this.reject(err)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -274,12 +274,16 @@ function checkChunkResponse(response) {
|
|||
* @param {AbortSignal} abortSignal
|
||||
*/
|
||||
export async function fallbackRequest({ url, start, end, abortSignal }) {
|
||||
const response = await fetch(url, {
|
||||
headers: { Range: `bytes=${start}-${end - 1}` },
|
||||
signal: abortSignal,
|
||||
})
|
||||
checkChunkResponse(response)
|
||||
return response.arrayBuffer()
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
headers: { Range: `bytes=${start}-${end - 1}` },
|
||||
signal: abortSignal,
|
||||
})
|
||||
checkChunkResponse(response)
|
||||
return await response.arrayBuffer()
|
||||
} catch (e) {
|
||||
throw OError.tag(e, 'fallback request failed', { url, start, end })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue