{"record":{"id":"f62f30650c19d37f","repo":"remotion-dev/remotion","slug":"parameter-memorysizeinmb-must-be-finite-but-is","errorCode":null,"errorMessage":"parameter 'memorySizeInMb' must be finite, but is ${memorySizeInMb}","messagePattern":"parameter 'memorySizeInMb' must be finite, but is (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/lambda-client/src/validate-memory-size.ts","lineNumber":15,"sourceCode":"import {MAX_MEMORY, MIN_MEMORY} from './constants';\n\nexport const validateMemorySize = (memorySizeInMb: unknown) => {\n\tif (typeof memorySizeInMb !== 'number') {\n\t\tthrow new TypeError(\n\t\t\t`parameter 'memorySizeInMb' must be a number, got a ${typeof memorySizeInMb}`,\n\t\t);\n\t}\n\n\tif (Number.isNaN(memorySizeInMb)) {\n\t\tthrow new TypeError(`parameter 'memorySizeInMb' must not be NaN, but is`);\n\t}\n\n\tif (!Number.isFinite(memorySizeInMb)) {\n\t\tthrow new TypeError(\n\t\t\t`parameter 'memorySizeInMb' must be finite, but is ${memorySizeInMb}`,\n\t\t);\n\t}\n\n\tif (memorySizeInMb < MIN_MEMORY || memorySizeInMb > MAX_MEMORY) {\n\t\tthrow new TypeError(\n\t\t\t`parameter 'memorySizeInMb' must be between ${MIN_MEMORY} and ${MAX_MEMORY}, but got ${memorySizeInMb}`,\n\t\t);\n\t}\n\n\tif (memorySizeInMb % 1 !== 0) {\n\t\tthrow new TypeError(\n\t\t\t`parameter 'memorySizeInMb' must be an integer but got ${memorySizeInMb}`,\n\t\t);\n\t}\n};\n","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda-client/src/validate-memory-size.ts#L1-L32","documentation":"Thrown by validateMemorySize() when memorySizeInMb is a non-finite number, i.e. Infinity or -Infinity. AWS Lambda cannot allocate infinite memory; valid sizes are integers in [512, 10240] MB. The guard sits after the NaN check, so only Infinity/-Infinity reaches this branch.","triggerScenarios":"Passing memorySizeInMb derived from Number('Infinity'), parseFloat('Infinity'), or an overflowing arithmetic expression (e.g. a huge divisor collapse). Also from a formula like maxMemory * factor where factor is unbounded.","commonSituations":"A config UI that lets the user type 'Infinity', an env var containing that literal, or a calculation that divides by zero yielding Infinity after rounding.","solutions":["Clamp the computed value with Math.min(Math.max(value, 512), 10240) so Infinity is capped before validation.","Reject non-finite inputs at the source using Number.isFinite() and substitute DEFAULT_MEMORY_SIZE (2048).","Audit the formula producing memorySizeInMb for divisions by zero or unbounded multipliers."],"exampleFix":"// before\nconst memorySizeInMb = maxFrames / 0; // Infinity\nawait renderMediaOnLambda({memorySizeInMb, ...});\n\n// after\nconst raw = maxFrames / divisor;\nconst memorySizeInMb = Number.isFinite(raw) ? Math.min(Math.max(Math.round(raw), 512), 10240) : 2048;\nawait renderMediaOnLambda({memorySizeInMb, ...});","handlingStrategy":"type-guard","validationCode":"const safeMemory = (v: unknown): number => {\n  const n = Number(v);\n  return Number.isFinite(n) ? Math.min(Math.max(Math.round(n), 512), 10240) : 2048;\n};","typeGuard":"const isMemorySize = (v: unknown): v is number =>\n  typeof v === 'number' && Number.isFinite(v) && v >= 512 && v <= 10240 && v % 1 === 0;","tryCatchPattern":null,"preventionTips":["Clamp computed memory values with Math.min/Math.max into [512, 10240].","Audit any formula that divides by a variable that could be zero.","Reject 'Infinity' / '-Infinity' literals at config-parsing time."],"tags":["lambda","validation","typescript","configuration"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}