{"record":{"id":"f7ad822ce49829cd","repo":"remotion-dev/remotion","slug":"lambda-function-returned-error-res-functionerro","errorCode":null,"errorMessage":"Lambda function returned error: ${res.FunctionError} ${res.LogResult}","messagePattern":"Lambda function returned error: (.+?) (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/lambda-client/src/call-lambda-sync.ts","lineNumber":37,"sourceCode":"\ttimeoutInTest,\n}: CallFunctionOptions<T, Provider>): Promise<\n\tOrError<ServerlessReturnValues<Provider>[T]>\n> => {\n\tconst Payload = JSON.stringify(payload);\n\tconst res = await getLambdaClient(\n\t\tregion as AwsRegion,\n\t\ttimeoutInTest,\n\t\tnull,\n\t).send(\n\t\tnew InvokeCommand({\n\t\t\tFunctionName: functionName,\n\t\t\tPayload,\n\t\t\tInvocationType: 'RequestResponse',\n\t\t}),\n\t);\n\n\tif (res.FunctionError) {\n\t\tthrow new Error(\n\t\t\t`Lambda function returned error: ${res.FunctionError} ${res.LogResult}`,\n\t\t);\n\t}\n\n\tif (!res.Payload) {\n\t\tthrow new Error(\n\t\t\t`Lambda function returned no payload (status ${res.StatusCode})`,\n\t\t);\n\t}\n\n\tconst decoded = new TextDecoder('utf-8').decode(res.Payload);\n\n\ttry {\n\t\treturn JSON.parse(decoded) as OrError<ServerlessReturnValues<Provider>[T]>;\n\t} catch {\n\t\tthrow new Error(`Invalid JSON: ${JSON.stringify(decoded)}`);\n\t}\n};","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda-client/src/call-lambda-sync.ts#L19-L55","documentation":"Thrown after a synchronous InvokeCommand when res.FunctionError is truthy. Lambda sets FunctionError when the handler itself raised (Unhandled) or returned a structured error (Handled). The message embeds the FunctionError code and the base64 LogResult so the function's own logs can be decoded.","triggerScenarios":"Any sync routine (getCompositionsOnLambda, non-streaming getRenderProgress, deleteRender, etc.) where the Lambda function code threw an exception. FunctionError is checked before payload decoding.","commonSituations":"Function OOM (memorySizeInMb too low), function timeout, version mismatch between lambda-client and deployed function, bad input that crashes the handler.","solutions":["Base64-decode the LogResult embedded in the error message to read the function's console output","If logs show OOM/timeout, raise memorySizeInMb or the function timeout and redeploy","Ensure the deployed function version matches the @remotion/lambda-client version","Open the CloudWatch log group for the function for the failing requestId"],"exampleFix":"// decode the LogResult field from the thrown message\ntry {\n  await getCompositionsOnLambda({...});\n} catch (err) {\n  const m = (err as Error).message.match(/LogResult\\'?\\s*=?\\s*([A-Za-z0-9+/=]+)/);\n  if (m) console.log(Buffer.from(m[1], 'base64').toString('utf-8'));\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await getCompositionsOnLambda({...});\n} catch (err) {\n  const msg = (err as Error).message;\n  if (msg.startsWith('Lambda function returned error')) {\n    const logResult = msg.split(' ').pop(); // base64 LogResult token\n    const logs = logResult ? Buffer.from(logResult, 'base64').toString('utf-8') : '';\n    // handle: log, bump memory, redeploy\n  }\n  throw err;\n}","preventionTips":["Keep deployed function version in sync with lambda-client version","Provision enough memorySizeInMb and timeout for your compositions","Smoke-test compositions locally before rendering on Lambda"],"tags":["aws","lambda","function-error","debugging"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}