{"record":{"id":"c5d592b1a79a10cc","repo":"remotion-dev/remotion","slug":"maxretries-is-nan-c5d592","errorCode":null,"errorMessage":"maxRetries is NaN","messagePattern":"maxRetries is NaN","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/lambda/src/shared/validate-retries.ts","lineNumber":15,"sourceCode":"export function validateMaxRetries(\n\tmaxRetries: unknown,\n): asserts maxRetries is number {\n\tif (typeof maxRetries !== 'number') {\n\t\tthrow new TypeError(\n\t\t\t'maxRetries must be a number, but is ' + JSON.stringify(maxRetries),\n\t\t);\n\t}\n\n\tif (!Number.isFinite(maxRetries)) {\n\t\tthrow new TypeError('maxRetries must be finite, but is ' + maxRetries);\n\t}\n\n\tif (Number.isNaN(maxRetries)) {\n\t\tthrow new TypeError('maxRetries is NaN');\n\t}\n\n\tif (maxRetries < 0) {\n\t\tthrow new TypeError(`maxRetries cannot be negative but is ${maxRetries}`);\n\t}\n\n\tif (maxRetries % 1 !== 0) {\n\t\tthrow new TypeError(\n\t\t\t`maxRetries should be an integer, but is ${maxRetries}.`,\n\t\t);\n\t}\n}\n","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda/src/shared/validate-retries.ts#L1-L28","documentation":"Thrown by validateMaxRetries() in @remotion/lambda when the 'maxRetries' option is the value NaN. maxRetries controls how many times the CLI retries a failed Lambda render/still invocation. Note: in the current source this exact message is effectively unreachable, because the preceding !Number.isFinite(maxRetries) check (validate-retries.ts:10) already rejects NaN (Number.isFinite(NaN) === false) and throws 'maxRetries must be finite, but is NaN' first. You will almost certainly see the finite error instead of this one.","triggerScenarios":"Calling renderMediaOnLambda() / renderStillOnLambda() or the `npx remotion lambda render|still --max-retries=<x>` CLI with maxRetries being the literal NaN, e.g. passed via Number(undefined), parseInt(undefined), parseFloat(undefined), or an arithmetic that evaluates to NaN.","commonSituations":"Reading maxRetries from an env var without validation (parseInt(process.env.RETRIES) when the var is unset), computing it from a malformed config file, or defaulting a missing numeric field to NaN instead of a number.","solutions":["Find where maxRetries is sourced and ensure it is a real integer; replace NaN with a sane default like the DEFAULT_MAX_RETRIES constant.","If parsing from env/config, coerce safely: const maxRetries = Number(process.env.RETRIES); if (!Number.isInteger(maxRetries)) maxRetries = DEFAULT_MAX_RETRIES;","Note you will likely see 'must be finite, but is NaN' first; treat both as the same root cause."],"exampleFix":"// before\nconst maxRetries = Number(process.env.RETRIES); // NaN when unset\nawait renderMediaOnLambda({ compositionId, serveUrl, inputProps, maxRetries });\n\n// after\nimport {DEFAULT_MAX_RETRIES} from '@remotion/lambda/client';\nconst parsed = Number(process.env.RETRIES);\nconst maxRetries = Number.isInteger(parsed) ? parsed : DEFAULT_MAX_RETRIES;","handlingStrategy":"validation","validationCode":"function safeMaxRetries(raw: unknown, fallback: number): number {\n  const n = typeof raw === 'number' ? raw : Number(raw);\n  if (!Number.isFinite(n) || n < 0 || n % 1 !== 0) return fallback;\n  return n;\n}\nconst maxRetries = safeMaxRetries(process.env.RETRIES, DEFAULT_MAX_RETRIES);","typeGuard":"const isMaxRetries = (v: unknown): v is number =>\n  typeof v === 'number' && Number.isFinite(v) && v >= 0 && v % 1 === 0;","tryCatchPattern":null,"preventionTips":["Always source maxRetries from a typed numeric constant (e.g. DEFAULT_MAX_RETRIES), not from an unchecked env parse.","Run validateMaxRetries early in your own pipeline so the error surfaces before any AWS call is made.","Treat NaN and 'must be finite' messages as the same defect: an unguarded numeric source."],"tags":["lambda","validation","max-retries","cli","configuration"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}