{"record":{"id":"a6c09a8689ff5d4f","repo":"stablyai/orca","slug":"file-too-large-stats-size-1024-1024-tofix","errorCode":null,"errorMessage":"File too large: ${(stats.size / 1024 / 1024).toFixed(1)}MB exceeds ${MAX_TEXT_FILE_SIZE / 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":178,"sourceCode":"  '.jpg': 'image/jpeg',\n  '.jpeg': 'image/jpeg',\n  '.gif': 'image/gif',\n  '.svg': 'image/svg+xml',\n  '.webp': 'image/webp',\n  '.bmp': 'image/bmp',\n  '.ico': 'image/x-icon',\n  '.pdf': 'application/pdf'\n}\nasync function readLocalLogSnapshot(filePath: string): Promise<{\n  content: string\n  isBinary: boolean\n  fileIdentity?: string\n}> {\n  const handle = await open(filePath, 'r')\n  try {\n    const stats = await handle.stat()\n    if (stats.size > MAX_TEXT_FILE_SIZE) {\n      throw new Error(\n        `File too large: ${(stats.size / 1024 / 1024).toFixed(1)}MB exceeds ${MAX_TEXT_FILE_SIZE / 1024 / 1024}MB limit`\n      )\n    }\n    const buffer = await handle.readFile()\n    if (buffer.byteLength > MAX_TEXT_FILE_SIZE) {\n      throw new Error(\n        `File too large: ${(buffer.byteLength / 1024 / 1024).toFixed(1)}MB exceeds ${MAX_TEXT_FILE_SIZE / 1024 / 1024}MB limit`\n      )\n    }\n    if (isBinaryBuffer(buffer)) {\n      return { content: '', isBinary: true }\n    }\n    return {\n      content: buffer.toString('utf8'),\n      isBinary: false,\n      fileIdentity: localLogFileIdentity(stats)\n    }\n  } finally {","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/filesystem.ts#L160-L196","documentation":"Thrown by readLocalLogSnapshot when the file's reported size (from fstat on the opened handle) exceeds MAX_TEXT_FILE_SIZE (50 MB). This function reads entire files into memory for log display, so the pre-read stat check prevents excessive memory consumption and Monaco editor degradation.","triggerScenarios":"Calling the fs:readFile IPC with includeLocalLogMetadata=true on a file whose stat.size exceeds 50 MB (50 * 1024 * 1024 bytes). The size is checked on the handle's fstat before readFile is called.","commonSituations":"Opening a large log file (server logs, application logs) that has grown past 50 MB. Reading a large text data file (CSV, JSON export) through the log-snapshot path. Attempting to view a concatenated or aggregated log archive.","solutions":["Use a log viewer or tail tool to inspect only the relevant portion of the large file.","Split the file into smaller chunks before opening.","Compress or archive old log entries to reduce the file below 50 MB."],"exampleFix":"// before: open a 80MB log file via includeLocalLogMetadata\n// after: tail or split the log first\n//   tail -c 52428800 large.log > recent.log\n//   open recent.log","handlingStrategy":"validation","validationCode":"const { stat } = await import('node:fs/promises')\nconst MAX_TEXT_FILE_SIZE = 50 * 1024 * 1024\n\nasync function assertLogUnderLimit(filePath: string): Promise<void> {\n  const s = await stat(filePath)\n  if (s.size > MAX_TEXT_FILE_SIZE) {\n    throw new Error(`${filePath} is ${(s.size / 1048576).toFixed(1)}MB, exceeds 50MB log snapshot limit`)\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const result = await ipcRenderer.invoke('fs:readFile', { filePath, includeLocalLogMetadata: true })\n} catch (error) {\n  if (error instanceof Error && error.message.startsWith('File too large')) {\n    showUserWarning(error.message + ' — use tail or split to view a portion.')\n    return\n  }\n  throw error\n}","preventionTips":["Check log file size with `ls -la` or `du -h` before opening in the log viewer.","Rotate or archive large logs to keep them under 50 MB.","Use `tail -n 1000` or `tail -c 50M` to view the relevant portion of large logs."],"tags":["size-limit","filesystem","log-snapshot","memory","ipc"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}