Skip to content

Commit 3420641

Browse files
committed
fix(file-parsers): only flag truncation when PDF text is actually dropped
1 parent b59f116 commit 3420641

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

apps/sim/lib/file-parsers/pdf-parser.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,14 @@ async function readPageWithinBudget(
6262
const parts: string[] = []
6363
let remaining = budget
6464
let completed = false
65+
let dropped = false
6566

6667
try {
67-
while (remaining > 0 && Date.now() <= deadline) {
68+
/**
69+
* Loops until content is actually dropped rather than until the budget hits
70+
* zero: text that ends exactly on the budget is complete, not truncated.
71+
*/
72+
while (!dropped && Date.now() <= deadline) {
6873
const { value, done } = await reader.read()
6974
if (done) {
7075
completed = true
@@ -78,6 +83,7 @@ async function readPageWithinBudget(
7883
if (piece.length > remaining) {
7984
parts.push(piece.slice(0, remaining))
8085
remaining = 0
86+
dropped = true
8187
break
8288
}
8389

0 commit comments

Comments
 (0)