remotion-dev/remotion · error · Error
Lambda function ${functionName} failed with error code ${eve
Error message
Lambda function ${functionName} failed with error code ${event.InvokeComplete.ErrorCode}: ${event.InvokeComplete.ErrorDetails}. See ${logs} to see the logs of this invocation. What it means
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.
Source
Thrown at packages/lambda-client/src/call-lambda-streaming.ts:158
// `PayloadChunk`: These contain the actual raw bytes of the chunk
// It has a single property: `Payload`
if (event.PayloadChunk && event.PayloadChunk.Payload) {
onData(event.PayloadChunk.Payload);
}
if (event.InvokeComplete) {
if (event.InvokeComplete.ErrorCode) {
const 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}))`;
if (event.InvokeComplete.ErrorCode === 'Unhandled') {
throw new Error(
`Lambda function ${functionName} failed with an unhandled error: ${
event.InvokeComplete.ErrorDetails as string
} See ${logs} to see the logs of this invocation.`,
);
}
throw new Error(
`Lambda function ${functionName} failed with error code ${event.InvokeComplete.ErrorCode}: ${event.InvokeComplete.ErrorDetails}. See ${logs} to see the logs of this invocation.`,
);
}
}
// Don't put a `break` statement here, as it will cause the socket to not properly exit.
}
// @ts-expect-error - We are adding a listener to a global variable
if (globalThis._dumpUnreleasedBuffers) {
// @ts-expect-error - We are adding a listener to a global variable
(globalThis._dumpUnreleasedBuffers as EventEmitter).removeListener(
'dump-unreleased-buffers',
dumpBuffers,
);
}
clear();View on GitHub (pinned to 78fe4bb3fd)
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.
Example fix
// before
await renderMediaOnLambda({ functionName: 'remotion-render' }); // TaskTimedOut after 120s
// after
await deployFunction({ memorySizeInMb: 2048, timeoutInSeconds: 300 });
await renderMediaOnLambda({ functionName: 'remotion-render' }); Defensive patterns
Strategy: try-catch
Try / catch
try {
await renderMediaOnLambda({ ... });
} catch (e) {
const msg = String((e as Error).message);
if (msg.includes('failed with error code')) {
// open the embedded CloudWatch URL; if timeout/OOM, redeploy with higher limits and retry
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Lambda function ${functionName} failed with an unhandled err
- Lambda function returned error: ${result.FunctionError} ${re
- Invalid JSON (${type}): ${asString}
- Payload is too big: ${stringifiedPayload.length} bytes. Maxi
- renderMediaOnLambda() has moved to `@remotion/lambda-client`
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/3b557ddfce55a5ed.
Report an issue: GitHub.