{"record":{"id":"3b557ddfce55a5ed","repo":"remotion-dev/remotion","slug":"lambda-function-functionname-failed-with-error","errorCode":null,"errorMessage":"Lambda function ${functionName} failed with error code ${event.InvokeComplete.ErrorCode}: ${event.InvokeComplete.ErrorDetails}. See ${logs} to see the logs of this invocation.","messagePattern":"Lambda function (.+?) failed with error code (.+?): (.+?)\\. See (.+?) to see the logs of this invocation\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/lambda-client/src/call-lambda-streaming.ts","lineNumber":158,"sourceCode":"\n\t\t// `PayloadChunk`: These contain the actual raw bytes of the chunk\n\t\t// It has a single property: `Payload`\n\t\tif (event.PayloadChunk && event.PayloadChunk.Payload) {\n\t\t\tonData(event.PayloadChunk.Payload);\n\t\t}\n\n\t\tif (event.InvokeComplete) {\n\t\t\tif (event.InvokeComplete.ErrorCode) {\n\t\t\t\tconst logs = `https://${region}.console.aws.amazon.com/cloudwatch/home?region=${region}#logsV2:logs-insights$3FqueryDetail$3D~(end~0~start~-3600~timeType~'RELATIVE~unit~'seconds~editorString~'fields*20*40timestamp*2c*20*40requestId*2c*20*40message*0a*7c*20filter*20*40requestId*20like*20*${res.$metadata.requestId}*22*0a*7c*20sort*20*40timestamp*20asc~source~(~'*2faws*2flambda*2f${functionName}))`;\n\t\t\t\tif (event.InvokeComplete.ErrorCode === 'Unhandled') {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Lambda function ${functionName} failed with an unhandled error: ${\n\t\t\t\t\t\t\tevent.InvokeComplete.ErrorDetails as string\n\t\t\t\t\t\t} See ${logs} to see the logs of this invocation.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Lambda function ${functionName} failed with error code ${event.InvokeComplete.ErrorCode}: ${event.InvokeComplete.ErrorDetails}. See ${logs} to see the logs of this invocation.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Don't put a `break` statement here, as it will cause the socket to not properly exit.\n\t}\n\n\t// @ts-expect-error - We are adding a listener to a global variable\n\tif (globalThis._dumpUnreleasedBuffers) {\n\t\t// @ts-expect-error - We are adding a listener to a global variable\n\t\t(globalThis._dumpUnreleasedBuffers as EventEmitter).removeListener(\n\t\t\t'dump-unreleased-buffers',\n\t\t\tdumpBuffers,\n\t\t);\n\t}\n\n\tclear();","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda-client/src/call-lambda-streaming.ts#L140-L176","documentation":"Thrown by the streaming invocation loop in @remotion/lambda-client when an InvokeComplete event arrives with a non-'Unhandled' ErrorCode. These are Lambda-level errors returned after the function began executing but failed in a controlled way that produced an error code (e.g. a handled exception escaped the handler, a timeout, or a resource limit). The message embeds a CloudWatch Logs Insights URL filtered to the requestId.","triggerScenarios":"The renderer function exceeds its configured timeout (ErrorCode 'Timeouts' / 'TaskTimedOut'), runs out of memory mid-render, throws a handled error that propagates out of the handler, or hits an AWS resource limit (e.g. ephemeral storage full).","commonSituations":"Long renders exceeding the deployed timeout; large compositions exhausting memory; bugs in user composition code that throw uncaught during server-side render; S3/ephemeral-storage exhaustion on big outputs.","solutions":["Open the CloudWatch Logs Insights URL in the error to see the specific failure and stack.","If it is a timeout: redeploy with a higher timeoutInSeconds (up to 900) or reduce the render chunk size / parallelism.","If it is a memory error: redeploy with more memorySizeInMb (also raises CPU).","If the user composition threw, fix the throwing code (reproduce locally with the same inputProps).","Upgrade @remotion/lambda and redeploy the function to rule out a fixed runtime defect."],"exampleFix":"// before\nawait renderMediaOnLambda({ functionName: 'remotion-render' }); // TaskTimedOut after 120s\n\n// after\nawait deployFunction({ memorySizeInMb: 2048, timeoutInSeconds: 300 });\nawait renderMediaOnLambda({ functionName: 'remotion-render' });","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await renderMediaOnLambda({ ... });\n} catch (e) {\n  const msg = String((e as Error).message);\n  if (msg.includes('failed with error code')) {\n    // open the embedded CloudWatch URL; if timeout/OOM, redeploy with higher limits and retry\n  }\n  throw e;\n}","preventionTips":["Deploy with a timeout (timeoutInSeconds up to 900) and memory sized for the composition.","Reproduce failing compositions locally with the same inputProps to catch user-code throws.","Keep the function and client versions aligned."],"tags":["lambda-client","streaming","aws-lambda","runtime-error","timeout","cloudwatch"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}