mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01: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:
@@ -843,13 +843,36 @@ export async function fetchRange({
|
|||||||
// | REQUESTED_RANGE |
|
// | REQUESTED_RANGE |
|
||||||
// | CHUNK |
|
// | CHUNK |
|
||||||
const offsetEnd = Math.max(chunk.end - end, 0)
|
const offsetEnd = Math.max(chunk.end - end, 0)
|
||||||
|
const oldDataLength = data.length
|
||||||
if (offsetStart > 0 || offsetEnd > 0) {
|
if (offsetStart > 0 || offsetEnd > 0) {
|
||||||
// compute index positions for slice to handle case where offsetEnd=0
|
// compute index positions for slice to handle case where offsetEnd=0
|
||||||
const chunkSize = chunk.end - chunk.start
|
const chunkSize = chunk.end - chunk.start
|
||||||
data = data.subarray(offsetStart, chunkSize - offsetEnd)
|
data = data.subarray(offsetStart, chunkSize - offsetEnd)
|
||||||
}
|
}
|
||||||
|
const newDataLength = data.length
|
||||||
const insertPosition = Math.max(chunk.start - start, 0)
|
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()
|
timer.finishBlockingCompute()
|
||||||
|
|||||||
Reference in New Issue
Block a user