remotion-dev/remotion · error · Error

Lambda function failed with error code : . See to see the…

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.

Solutions

  1. Open the CloudWatch Logs Insights URL in the error to see the specific failure and stack.
  2. If it is a timeout: redeploy with a higher timeoutInSeconds (up to 900) or reduce the render chunk size / parallelism.
  3. If it is a memory error: redeploy with more memorySizeInMb (also raises CPU).
  4. If the user composition threw, fix the throwing code (reproduce locally with the same inputProps).
  5. 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

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


AI-assisted analysis of remotion-dev/remotion@10db9de073 (2026-08-22). Data as JSON: /api/errors/3b557ddfce55a5ed. Report an issue: GitHub.

Appendix: source

Thrown at packages/lambda-client/src/call-lambda-streaming.ts:177

			if (event.PayloadChunk && event.PayloadChunk.Payload) {
				// Awaiting applies backpressure to the response stream when the
				// payload is being streamed to a sink
				await onData(event.PayloadChunk.Payload);
			}

			if (event.InvokeComplete) {
				if (event.InvokeComplete.ErrorCode) {
					const {consoleDomain} = getAwsRegionMetadata(region as AwsRegion);
					const logs = `https://${region}.${consoleDomain}/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.
		}
	} finally {
		// @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,
			);
		}

		// Also closes the active payload sink if the stream aborted

View on GitHub (pinned to 10db9de073)