{"record":{"id":"a0b87dda4af2f456","repo":"stablyai/orca","slug":"file-too-large-stats-size-1024-1024-tofix-a0b87d","errorCode":null,"errorMessage":"File too large: ${(stats.size / 1024 / 1024).toFixed(1)}MB exceeds ${sizeLimit / 1024 / 1024}MB limit","messagePattern":"File too large: (.+?)MB exceeds (.+?)MB limit","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"src/main/ipc/filesystem.ts","lineNumber":606,"sourceCode":"      content: string\n      isBinary: boolean\n      isImage?: boolean\n      mimeType?: string\n      fileIdentity?: string\n    }> => {\n      if (args.connectionId) {\n        const provider = requireSshFilesystemProvider(args.connectionId)\n        return provider.readFile(args.filePath)\n      }\n      const filePath = await resolveAuthorizedPath(args.filePath, store)\n      if (args.includeLocalLogMetadata === true) {\n        return readLocalLogSnapshot(filePath)\n      }\n      const stats = await stat(filePath)\n      const mimeType = PREVIEWABLE_BINARY_MIME_TYPES[extname(filePath).toLowerCase()]\n      const sizeLimit = mimeType ? MAX_PREVIEWABLE_BINARY_SIZE : MAX_TEXT_FILE_SIZE\n      if (stats.size > sizeLimit) {\n        throw new Error(\n          `File too large: ${(stats.size / 1024 / 1024).toFixed(1)}MB exceeds ${sizeLimit / 1024 / 1024}MB limit`\n        )\n      }\n\n      if (mimeType) {\n        const buffer = await readFile(filePath)\n        return {\n          content: buffer.toString('base64'),\n          isBinary: true,\n          // Why: the renderer keys previewable-binary rendering off `isImage`, so set it for PDFs too to stay compatible.\n          isImage: true,\n          mimeType\n        }\n      }\n\n      // Why: probe large unknown files first so archives aren't fully buffered only to discover they aren't editable text.\n      if (stats.size > BINARY_PROBE_BYTES && (await isBinaryFilePrefix(filePath))) {\n        return { content: '', isBinary: true }","sourceCodeStart":588,"sourceCodeEnd":624,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/filesystem.ts#L588-L624","documentation":"Thrown by the fs:readFile IPC handler when a file exceeds its size limit. The limit is 50 MB for previewable binary types (images, PDFs) and 50 MB for all other files. The check uses stat on the file path before reading, so oversized files are rejected early to prevent memory exhaustion from buffering entire files into base64 or UTF-8 strings.","triggerScenarios":"Calling fs:readFile (without includeLocalLogMetadata) on a local file whose stat.size exceeds the applicable limit. For previewable binaries (.png, .jpg, .jpeg, .gif, .svg, .webp, .bmp, .ico, .pdf) the limit is MAX_PREVIEWABLE_BINARY_SIZE (50 MB); for all other files it is MAX_TEXT_FILE_SIZE (50 MB).","commonSituations":"Opening a large image, PDF, video, or binary file in the file viewer. Reading a large source file, data export, or log through the general readFile path. Attempting to preview a high-resolution image or multi-page PDF.","solutions":["Reduce the file size: compress images, split PDFs, or truncate data files.","For images, downscale or convert to a more compact format.","Open the file in an external application designed for large files instead of through the in-app viewer."],"exampleFix":"// before: open a 60MB PDF via fs:readFile\n// after: compress or split the PDF\n//   gs -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -o compressed.pdf large.pdf\n//   open compressed.pdf","handlingStrategy":"validation","validationCode":"const { stat } = await import('node:fs/promises')\nconst { extname } = await import('node:path')\n\nconst MAX_TEXT_FILE_SIZE = 50 * 1024 * 1024\nconst MAX_PREVIEWABLE_BINARY_SIZE = 50 * 1024 * 1024\nconst PREVIEWABLE = ['.png', '.jpg', '.jpeg', '.gif', '.svg', '.webp', '.bmp', '.ico', '.pdf']\n\nasync function assertFileUnderReadLimit(filePath: string): Promise<void> {\n  const s = await stat(filePath)\n  const ext = extname(filePath).toLowerCase()\n  const limit = PREVIEWABLE.includes(ext) ? MAX_PREVIEWABLE_BINARY_SIZE : MAX_TEXT_FILE_SIZE\n  if (s.size > limit) {\n    throw new Error(`${filePath} is ${(s.size / 1048576).toFixed(1)}MB, exceeds ${(limit / 1048576).toFixed(0)}MB read limit`)\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const result = await ipcRenderer.invoke('fs:readFile', { filePath })\n} catch (error) {\n  if (error instanceof Error && error.message.startsWith('File too large')) {\n    showUserWarning(error.message + ' — reduce the file size or open in an external app.')\n    return\n  }\n  throw error\n}","preventionTips":["Check file size with `ls -la` or `du -h` before opening in the in-app viewer.","Compress or downscale large images and PDFs before viewing.","Use external applications for files that consistently exceed the 50 MB limit."],"tags":["size-limit","filesystem","read-file","memory","ipc"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}