{"record":{"id":"ec716aecb5ec09a4","repo":"remotion-dev/remotion","slug":"remote-asset-exceeds-the-50mb-size-limit","errorCode":null,"errorMessage":"Remote asset exceeds the 50MB size limit","messagePattern":"Remote asset exceeds the 50MB size limit","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/browser-studio/src/download-remote-asset.ts","lineNumber":77,"sourceCode":"\t\t\tif (error instanceof Error && error.name === 'AbortError') {\n\t\t\t\tthrow new Error('Timed out downloading remote asset');\n\t\t\t}\n\n\t\t\tthrow new Error(\n\t\t\t\t`Could not fetch remote asset. The URL may not allow cross-origin requests (CORS): ${\n\t\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t\t}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!response.ok) {\n\t\t\tthrow new Error(`Could not download remote asset: ${response.status}`);\n\t\t}\n\n\t\tconst contentLength = response.headers.get('content-length');\n\t\tif (contentLength !== null && Number(contentLength) > maxRemoteAssetSize) {\n\t\t\tabortController.abort();\n\t\t\tthrow new Error('Remote asset exceeds the 50MB size limit');\n\t\t}\n\n\t\tif (!response.body) {\n\t\t\tconst buffer = await response.arrayBuffer();\n\t\t\tif (buffer.byteLength > maxRemoteAssetSize) {\n\t\t\t\tthrow new Error('Remote asset exceeds the 50MB size limit');\n\t\t\t}\n\n\t\t\tcontents = new Uint8Array(buffer);\n\t\t} else {\n\t\t\tconst reader = response.body.getReader();\n\t\t\tconst chunks: Uint8Array[] = [];\n\t\t\tlet size = 0;\n\n\t\t\twhile (true) {\n\t\t\t\tconst {done, value} = await reader.read();\n\t\t\t\tif (done) {\n\t\t\t\t\tbreak;","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/remotion-dev/remotion/blob/10db9de07356446fb0edb3c3ae211369b693d18b/packages/browser-studio/src/download-remote-asset.ts#L59-L95","documentation":"Thrown by downloadRemoteAsset in @remotion/browser-studio when the asset exceeds maxRemoteAssetSize (50MB). It is checked three ways: a Content-Length header that already exceeds the limit (download is aborted immediately), a fully-buffered body that is too large, and a running byte count while streaming that crosses the limit (stream is cancelled). The cap keeps oversized payloads out of the in-browser virtual project.","triggerScenarios":"Calling `downloadRemoteAsset({url})` for an image whose Content-Length > 50MB; a server omitting Content-Length and streaming more than 50MB; uncompressed TIFF/raw photos or huge PNGs from a camera or design tool.","commonSituations":"Users importing print-resolution or raw camera images; servers reporting wrong Content-Length; multi-frame sprite sheets.","solutions":["Downscale/compress the image below 50MB (e.g. export as WebP/JPEG) and import that","Host a properly sized derivative and import its URL instead","If you control the pipeline, pre-process assets server-side before they reach Browser Studio","Do not retry the same URL — the size check is deterministic while the file is unchanged"],"exampleFix":"// before\nawait operations.downloadRemoteAsset({url: rawPhotoUrl}); // 80MB TIFF -> rejects\n\n// after\nconst head = await fetch(rawPhotoUrl, {method: 'HEAD'});\nconst size = Number(head.headers.get('content-length') ?? 0);\nif (size > 50 * 1024 * 1024) {\n  throw new Error('Image is over 50MB — compress it before importing');\n}\nawait operations.downloadRemoteAsset({url: rawPhotoUrl});","handlingStrategy":"validation","validationCode":"const head = await fetch(url, {method: 'HEAD'});\nconst len = Number(head.headers.get('content-length') ?? 0);\nif (len > 50 * 1024 * 1024) {\n  throw new Error('Image exceeds the 50MB import limit — compress it first');\n}\nawait operations.downloadRemoteAsset({url});","typeGuard":null,"tryCatchPattern":"try { await operations.downloadRemoteAsset({url}); } catch (error) { if (error instanceof Error && error.message.includes('50MB size limit')) { /* prompt user to compress */ } else throw error; }","preventionTips":["Check Content-Length via HEAD before starting the import when the host provides it","Pre-process user uploads server-side (resize/compress) rather than importing originals","Do not retry the same URL after this error — the outcome is deterministic"],"tags":["asset-import","size-limit","validation","browser-studio"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"10db9de07356446fb0edb3c3ae211369b693d18b","analyzedAt":"2026-08-22T21:45:17.748Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}