There was an error while loading. Please reload this page.
1 parent b59f116 commit 3420641Copy full SHA for 3420641
1 file changed
apps/sim/lib/file-parsers/pdf-parser.ts
@@ -62,9 +62,14 @@ async function readPageWithinBudget(
62
const parts: string[] = []
63
let remaining = budget
64
let completed = false
65
+ let dropped = false
66
67
try {
- 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) {
73
const { value, done } = await reader.read()
74
if (done) {
75
completed = true
@@ -78,6 +83,7 @@ async function readPageWithinBudget(
78
83
if (piece.length > remaining) {
79
84
parts.push(piece.slice(0, remaining))
80
85
remaining = 0
86
+ dropped = true
81
87
break
82
88
}
89
0 commit comments