mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #4170 from overleaf/bg-add-serviceworker-metrics-for-fallback-requests
add metrics for fallback requests in service worker GitOrigin-RevId: 092e0dd31e45e522c31508334f53bd6642054371
This commit is contained in:
parent
c774ddd111
commit
fb249cb24f
1 changed files with 5 additions and 1 deletions
|
@ -236,10 +236,12 @@ function processPdfRequest(
|
|||
const chunks = getMatchingChunks(file.ranges, start, end)
|
||||
const dynamicChunks = getInterleavingDynamicChunks(chunks, start, end)
|
||||
const chunksSize = countBytes(chunks)
|
||||
const size = end - start
|
||||
|
||||
if (chunks.length + dynamicChunks.length > MAX_SUBREQUEST_COUNT) {
|
||||
// fall back to the original range request when splitting the range creates
|
||||
// too many subrequests.
|
||||
trackDownloadStats(metrics, { size, cachedBytes: 0, fetchedBytes: size })
|
||||
return
|
||||
}
|
||||
if (
|
||||
|
@ -249,6 +251,7 @@ function processPdfRequest(
|
|||
// fall back to the original range request when a very large amount of
|
||||
// object data would be requested, unless it is the only object in the
|
||||
// request.
|
||||
trackDownloadStats(metrics, { size, cachedBytes: 0, fetchedBytes: size })
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -277,7 +280,6 @@ function processPdfRequest(
|
|||
}
|
||||
})
|
||||
)
|
||||
const size = end - start
|
||||
let cachedBytes = 0
|
||||
let fetchedBytes = 0
|
||||
const reAssembledBlob = new Uint8Array(size)
|
||||
|
@ -378,6 +380,8 @@ function processPdfRequest(
|
|||
})
|
||||
})
|
||||
.catch(error => {
|
||||
fetchedBytes += size
|
||||
trackDownloadStats(metrics, { size, cachedBytes: 0, fetchedBytes })
|
||||
reportError(event, OError.tag(error, 'failed to compose pdf response'))
|
||||
return fetch(event.request)
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue