mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-30 18:31:26 +00:00
Merge pull request #10231 from overleaf/jpa-pdf-caching-bounds-debug
[web] pdf-caching: debug bounds when reassembling the range from chunks GitOrigin-RevId: 11871241d07880ebd2659cc5d0feb1f2c29014b6
This commit is contained in:
parent
0e09c25a97
commit
79e6fecc4a
1 changed files with 24 additions and 1 deletions
|
@ -843,13 +843,36 @@ export async function fetchRange({
|
|||
// | REQUESTED_RANGE |
|
||||
// | CHUNK |
|
||||
const offsetEnd = Math.max(chunk.end - end, 0)
|
||||
const oldDataLength = data.length
|
||||
if (offsetStart > 0 || offsetEnd > 0) {
|
||||
// compute index positions for slice to handle case where offsetEnd=0
|
||||
const chunkSize = chunk.end - chunk.start
|
||||
data = data.subarray(offsetStart, chunkSize - offsetEnd)
|
||||
}
|
||||
const newDataLength = data.length
|
||||
const insertPosition = Math.max(chunk.start - start, 0)
|
||||
reassembledBlob.set(data, insertPosition)
|
||||
try {
|
||||
reassembledBlob.set(data, insertPosition)
|
||||
} catch (err) {
|
||||
const reassembledBlobLength = reassembledBlob.length
|
||||
const trimmedChunk = {
|
||||
start: chunk.start,
|
||||
end: chunk.end,
|
||||
hash: chunk.hash,
|
||||
objectId: new TextDecoder().decode(chunk.objectId),
|
||||
}
|
||||
throw OError.tag(err, 'broken reassembly', {
|
||||
start,
|
||||
end,
|
||||
chunk: trimmedChunk,
|
||||
oldDataLength,
|
||||
newDataLength,
|
||||
offsetStart,
|
||||
offsetEnd,
|
||||
insertPosition,
|
||||
reassembledBlobLength,
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
timer.finishBlockingCompute()
|
||||
|
|
Loading…
Reference in a new issue