{"record":{"id":"ec85834b612aa744","repo":"remotion-dev/remotion","slug":"maxretries-must-be-finite-but-is-maxretries","errorCode":null,"errorMessage":"maxRetries must be finite, but is ${maxRetries}","messagePattern":"maxRetries must be finite, but is (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/cloudrun/src/shared/validate-retries.ts","lineNumber":11,"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/cloudrun/src/shared/validate-retries.ts#L1-L28","documentation":"Thrown by validateMaxRetries() when maxRetries is a number but fails Number.isFinite(), i.e. it is Infinity or -Infinity. This guard sits between the type check and the NaN check, and because Number.isFinite(NaN) is also false, a NaN value will hit this branch (rendered as '...must be finite, but is NaN') rather than the dedicated NaN branch below it.","triggerScenarios":"Passing Infinity, -Infinity, or NaN as maxRetries. NaN typically arrives from arithmetic on undefined (e.g. Number(undefined) is NaN) or a failed Number() coercion; Infinity can come from division by zero or explicit constants.","commonSituations":"Computing retries from a formula that divides by a zero/undefined denominator; using Number(maybeUndefined) without a fallback; parsing user input that is empty and coerces to NaN.","solutions":["Validate with Number.isFinite() and substitute a sane default (e.g. 1) before calling the API.","Trace the source of the value: confirm the arithmetic producing maxRetries never divides by zero or operates on undefined.","If the value is user-supplied, reject non-finite input in your own validation layer."],"exampleFix":"// before\nconst maxRetries = total / shards; // shards could be 0 -> Infinity\n\n// after\nconst maxRetries = Number.isFinite(total / shards) ? total / shards : 1;","handlingStrategy":"validation","validationCode":"if (!Number.isFinite(maxRetries)) {\n  throw new RangeError('maxRetries must be a finite number');\n}","typeGuard":"const isFiniteNumber = (v: unknown): v is number =>\n  typeof v === 'number' && Number.isFinite(v);","tryCatchPattern":null,"preventionTips":["Coerce untrusted input with Number() then guard with Number.isFinite() before use.","Avoid arithmetic that can divide by zero when computing retry counts.","Provide a numeric fallback whenever the source value is optional."],"tags":["cloudrun","validation","typescript","numeric"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}