{"record":{"id":"3d5e7d43f0ae3657","repo":"chatboxai/chatbox","slug":"local-parser-file-too-large-3d5e7d","errorCode":null,"errorMessage":"local_parser_file_too_large","messagePattern":"local_parser_file_too_large","errorType":"error_code","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"src/renderer/packages/pdf-parser.ts","lineNumber":42,"sourceCode":"    'str' in item &&\n    typeof (item as PdfTextItem).str === 'string' &&\n    Array.isArray((item as PdfTextItem).transform)\n  )\n}\n\nasync function loadPdfjs() {\n  const pdfjs = await import('pdfjs-dist/legacy/build/pdf.mjs')\n  pdfjs.GlobalWorkerOptions.workerSrc = pdfWorkerUrl\n  return pdfjs\n}\n\nexport async function parsePdfFileLocally(file: File): Promise<string> {\n  if (!isPdfFilePath(file.name)) {\n    throw new Error('local_parser_failed')\n  }\n\n  if (file.size > LOCAL_PARSER_MAX_PDF_FILE_SIZE) {\n    throw new Error(LOCAL_PARSER_FILE_TOO_LARGE_ERROR)\n  }\n\n  const { getDocument } = await loadPdfjs()\n  const loadingTask = getDocument({\n    data: new Uint8Array(await file.arrayBuffer()),\n    useSystemFonts: true,\n  })\n\n  try {\n    const document = await loadingTask.promise\n    const pageTexts: string[] = []\n\n    for (let pageNumber = 1; pageNumber <= document.numPages; pageNumber++) {\n      try {\n        const page = await document.getPage(pageNumber)\n        try {\n          const textContent = await page.getTextContent()\n          let pageText = ''","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/renderer/packages/pdf-parser.ts#L24-L60","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Compress or split the PDF to get under LOCAL_PARSER_MAX_PDF_FILE_SIZE.","Extract only the relevant pages and attach those.","Route the file through the server-side/remote parser path if available for large files."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (file.size > LOCAL_PARSER_MAX_PDF_FILE_SIZE) {\n  // offer server-side parse or reject; do not call parsePdfFileLocally\n}","typeGuard":"function pdfWithinLocalLimit(file: File): boolean {\n  return file.size <= LOCAL_PARSER_MAX_PDF_FILE_SIZE\n}","tryCatchPattern":"try {\n  await parsePdfFileLocally(file)\n} catch (e) {\n  if (e instanceof Error && e.message === LOCAL_PARSER_FILE_TOO_LARGE_ERROR) {\n    // switch to server-side/remote parser\n  }\n}","preventionTips":["Show the size limit in the attachment UI.","Offer to compress/split before attaching.","Prefer server-side parsing for files near the cap."],"tags":["pdf","parser","file-size","validation"],"backgroundTag":null,"analyzedSha":"81571269addb6bafb589a920b2883f1e1e084fd1","analyzedAt":"2026-08-12T21:51:44.981Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}