remotion-dev/remotion · error · Exception

Failed to invoke Lambda function

Error message

Failed to invoke Lambda function

What it means

Thrown by invokeLambdaFunction when the Lambda Invoke response's StatusCode is not 200. Note this check is coarse: a 200 with a FunctionError or error payload is handled separately downstream (1197/1199). A non-200 here means the request never reached a successful invocation — function not found, throttled, or service error. The message is static and does not include the body or error code, which makes diagnosis harder.

Source

Thrown at packages/lambda-php/src/PHPClient.php:306

    }

    public function getRenderProgress(string $renderId, string $bucketName, string $logLevel = "info", $forcePathStyle = false): GetRenderProgressResponse
    {
        $payload = $this->makeRenderProgressPayload($renderId, $bucketName, $logLevel, $forcePathStyle);
        $result = $this->invokeLambdaFunction($payload);
        return $this->handleLambdaResponseProgress($result);
    }

    private function invokeLambdaFunction(string $payload)
    {
        $result = $this->client->invoke([
            'InvocationType' => 'RequestResponse',
            'FunctionName' => $this->getFunctionName(),
            'Payload' => $payload,
        ]);

        if ($result['StatusCode'] !== 200) {
            throw new Exception("Failed to invoke Lambda function");
        }

        return $result['Payload']->getContents();
    }

    private function handleLambdaResponseRender(string $response): RenderMediaOnLambdaResponse
    {
        $response = json_decode($response, true);

        // AWS response
        if (isset($response->errorMessage)) {
            throw new Exception($response->errorMessage);
        }

        $classResponse = new RenderMediaOnLambdaResponse();

        // Remotion response
        if ($response['type'] === 'error') {

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Check $result['StatusCode'] and log the full $result (including FunctionError and Payload) — the static message hides the cause.
  2. Verify getFunctionName() returns the deployed function name in the correct region (`aws lambda get-function`).
  3. Grant lambda:InvokeFunction to the caller's IAM role.
  4. For 429/5xx, add exponential backoff around the invoke call.
  5. Improve the library to include $result['FunctionError'] / Payload in the exception message.

Example fix

// before
if ($result['StatusCode'] !== 200) {
    throw new Exception("Failed to invoke Lambda function");
}

// after - include the status and function error so the cause is diagnosable
if ($result['StatusCode'] !== 200) {
    $fnError = $result['FunctionError'] ?? 'none';
    $body = $result['Payload']->getContents();
    throw new Exception(sprintf(
        "Failed to invoke Lambda function %s (status %d, functionError %s): %s",
        $this->getFunctionName(),
        $result['StatusCode'],
        $fnError,
        $body
    ));
}
Defensive patterns

Strategy: retry

Try / catch

try {
    $body = $this->invokeLambdaFunction($payload);
} catch (Exception $e) {
    // The static message hides the cause; log $result and FunctionError,
    // retry only on transient (429/5xx) conditions.
    throw $e;
}

Prevention

When it happens

Trigger: $this->client->invoke returns a result whose StatusCode is 202 (sync invocation accepted but not 200 in some configurations), 4xx (AccessDenied, ResourceNotFound), 429 (TooManyRequests), or 5xx (AWS service error).

Common situations: Function name misconfigured. Caller role lacks lambda:InvokeFunction. AWS throttling under burst. Service-side 5xx during a regional event.

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/b25341eabc57b306. Report an issue: GitHub.