{"record":{"id":"09ef1b7b67e8135e","repo":"heygen-com/hyperframes","slug":"figma-render-download-failed-content-length-dec","errorCode":null,"errorMessage":"figma render download failed: content-length ${declared} exceeds ${MAX_FREEZE_BYTES} cap","messagePattern":"figma render download failed: content-length (.+?) exceeds (.+?) cap","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/figma/download.ts","lineNumber":11,"sourceCode":"import { exceedsFreezeCap, MAX_FREEZE_BYTES } from \"@hyperframes/core/figma\";\n\n/** Fetch a short-lived figma CDN render url into bytes. */\nexport async function downloadRender(url: string): Promise<Uint8Array> {\n  const res = await fetch(url);\n  if (!res.ok) throw new Error(`figma render download failed: HTTP ${res.status}`);\n  // Reject oversized responses before buffering the body — the freeze cap\n  // alone only fires after the full allocation.\n  const declared = Number(res.headers.get(\"content-length\") ?? 0);\n  if (exceedsFreezeCap(declared))\n    throw new Error(\n      `figma render download failed: content-length ${declared} exceeds ${MAX_FREEZE_BYTES} cap`,\n    );\n  return new Uint8Array(await res.arrayBuffer());\n}\n","sourceCodeStart":1,"sourceCodeEnd":16,"githubUrl":"https://github.com/heygen-com/hyperframes/blob/c2996c8626135db5253519359d8a063d3bafad8d/packages/cli/src/commands/figma/download.ts#L1-L16","documentation":"Thrown by downloadRender() before buffering the body: it reads the response content-length header and rejects it if it exceeds MAX_FREEZE_BYTES (256 MiB). This is the ponytail disk-fill guard — a hostile or runaway source cannot exhaust disk through an oversized render. The cap value is interpolated into the message.","triggerScenarios":"A render whose declared size is over 256 MiB: a very high --scale on a large frame, or an svg export of an extremely complex vector tree. The check fires on the declared content-length, before any byte is buffered.","commonSituations":"Passing --scale 4 on a big frame; exporting a dense illustration as svg at high scale; an unexpected huge payload from figma.","solutions":["Lower --scale (e.g. 2 or 1)","Export a smaller node, or split a large frame into smaller nodes","Switch format — svg of complex frames can be enormous; png at modest scale is usually far smaller"],"exampleFix":"// before\nhyperframes figma asset AAA:1:2 --format svg --scale 4\n// after\nhyperframes figma asset AAA:1:2 --format png --scale 2","handlingStrategy":"validation","validationCode":"import { MAX_FREEZE_BYTES } from '@hyperframes/core/figma';\n// Before requesting a render, cap the scale to keep the expected payload under 256 MiB.\nconst safeScale = Math.min(requestedScale ?? 1, 2); // svg of complex frames is large; start low","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep --scale modest (1 or 2) for large frames","Prefer png over svg for very complex vectors, which balloon in size","Remember the cap is 256 MiB (MAX_FREEZE_BYTES) on the declared content-length"],"tags":["figma","download","size-cap","validation"],"backgroundTag":null,"analyzedSha":"c2996c8626135db5253519359d8a063d3bafad8d","analyzedAt":"2026-08-12T22:18:56.877Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}