chatboxai/chatbox · warning · Error

local_parser_file_too_large

Error message

local_parser_file_too_large

What it means

Thrown by parsePdfFileLocally() when file.size exceeds LOCAL_PARSER_MAX_PDF_FILE_SIZE. It protects the renderer from loading oversized PDFs into the client-side pdfjs worker, which would freeze or OOM the page. The sentinel string lets callers offer server-side parsing as an alternative.

Source

Thrown at src/renderer/packages/pdf-parser.ts:42

    'str' in item &&
    typeof (item as PdfTextItem).str === 'string' &&
    Array.isArray((item as PdfTextItem).transform)
  )
}

async function loadPdfjs() {
  const pdfjs = await import('pdfjs-dist/legacy/build/pdf.mjs')
  pdfjs.GlobalWorkerOptions.workerSrc = pdfWorkerUrl
  return pdfjs
}

export async function parsePdfFileLocally(file: File): Promise<string> {
  if (!isPdfFilePath(file.name)) {
    throw new Error('local_parser_failed')
  }

  if (file.size > LOCAL_PARSER_MAX_PDF_FILE_SIZE) {
    throw new Error(LOCAL_PARSER_FILE_TOO_LARGE_ERROR)
  }

  const { getDocument } = await loadPdfjs()
  const loadingTask = getDocument({
    data: new Uint8Array(await file.arrayBuffer()),
    useSystemFonts: true,
  })

  try {
    const document = await loadingTask.promise
    const pageTexts: string[] = []

    for (let pageNumber = 1; pageNumber <= document.numPages; pageNumber++) {
      try {
        const page = await document.getPage(pageNumber)
        try {
          const textContent = await page.getTextContent()
          let pageText = ''

View on GitHub (pinned to 81571269ad)

Solutions

  1. Compress or split the PDF to get under LOCAL_PARSER_MAX_PDF_FILE_SIZE.
  2. Extract only the relevant pages and attach those.
  3. Route the file through the server-side/remote parser path if available for large files.
Defensive patterns

Strategy: validation

Validate before calling

if (file.size > LOCAL_PARSER_MAX_PDF_FILE_SIZE) {
  // offer server-side parse or reject; do not call parsePdfFileLocally
}

Type guard

function pdfWithinLocalLimit(file: File): boolean {
  return file.size <= LOCAL_PARSER_MAX_PDF_FILE_SIZE
}

Try / catch

try {
  await parsePdfFileLocally(file)
} catch (e) {
  if (e instanceof Error && e.message === LOCAL_PARSER_FILE_TOO_LARGE_ERROR) {
    // switch to server-side/remote parser
  }
}

Prevention

When it happens

Trigger: Attaching a PDF larger than the configured LOCAL_PARSER_MAX_PDF_FILE_SIZE byte limit; the check `file.size > LOCAL_PARSER_MAX_PDF_FILE_SIZE` fires before getDocument is called.

Common situations: User attaches a large scanned-document PDF (image-heavy, many pages); a batch/book PDF exceeding the per-file cap; the limit was lowered in a newer build and previously-acceptable files now fail.

Related errors


AI-assisted analysis of chatboxai/chatbox@81571269ad (2026-08-12). Data as JSON: /api/errors/3d5e7d43f0ae3657. Report an issue: GitHub.