remotion-dev/remotion · error · Exception

Could not cancel render {$renderId}: {$exception->getMessage

Error message

Could not cancel render {$renderId}: {$exception->getMessage()}

What it means

cancelRenderOnLambda() passed the opt-in check and then wrote renders/{renderId}/cancel.json into the render bucket via writeCancellationToS3() (an S3 PutObject). Any Throwable from that AWS call - missing permissions, wrong bucket or region, network failure - is wrapped in a generic Exception 'Could not cancel render ...'; the previous exception carries the underlying AWS SDK error.

Source

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

        }

        if (($progress['cancellationEnabled'] ?? false) !== true) {
            throw new InvalidArgumentException(
                "Cannot cancel render {$renderId}: The render was not started with enableCancellation: true."
            );
        }

        try {
            $this->writeCancellationToS3(
                $bucketName,
                "renders/{$renderId}/cancel.json",
                json_encode(
                    ['cancelledAt' => (int) floor(microtime(true) * 1000)],
                    JSON_THROW_ON_ERROR
                )
            );
        } catch (\Throwable $exception) {
            throw new Exception("Could not cancel render {$renderId}: {$exception->getMessage()}", 0, $exception);
        }
    }

    protected function readProgressFromS3(string $bucketName, string $key): string
    {
        $result = $this->createS3Client()->getObject([
            'Bucket' => $bucketName,
            'Key' => $key,
        ]);

        return (string) $result['Body'];
    }

    protected function writeCancellationToS3(string $bucketName, string $key, string $body): void
    {
        $this->createS3Client()->putObject([
            'Bucket' => $bucketName,
            'Key' => $key,

View on GitHub (pinned to 10db9de073)

Solutions

  1. Unwrap the cause: inspect $exception->getPrevious() - the AWS error code (AccessDenied, NoSuchBucket, InvalidAccessKeyId, SlowDown) identifies the real problem.
  2. Grant s3:PutObject on arn:aws:s3:::<bucket>/renders/* to the IAM user or role the PHP client runs with.
  3. Verify the bucket name and region passed to PHPClient exactly match the values from the render response.
  4. Retry the cancel once if the cause was transient (5xx, SlowDown, timeout) - the write only replaces cancel.json with a fresh timestamp and is idempotent.
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-flight: confirm the canceling credentials can write to the render bucket
$s3 = new \Aws\S3\S3Client(['version' => 'latest', 'region' => $region, 'credentials' => $creds]);
try {
    $s3->putObject([
        'Bucket' => $bucketName,
        'Key' => 'renders/_cancel-write-test',
        'Body' => '{}',
    ]);
    $s3->deleteObject(['Bucket' => $bucketName, 'Key' => 'renders/_cancel-write-test']);
} catch (\Aws\Exception\AWSException $e) {
    // fix IAM before rendering, not during a cancel emergency
}

Try / catch

use Remotion\Lambda\Exception\Exception as RemotionException;

try {
    $client->cancelRenderOnLambda($renderId, $bucketName);
} catch (\Throwable $e) {
    $cause = $e->getPrevious();
    if ($cause instanceof \Aws\Exception\AWSException) {
        $code = $cause->getAwsErrorCode();
        if (in_array($code, ['SlowDown', 'RequestTimeout'], true)) { /* retry once */ }
        if ($code === 'AccessDenied') { /* fix s3:PutObject on renders/* */ }
    }
    throw $e;
}

Prevention

When it happens

Trigger: The credentials/role used by PHPClient lack s3:PutObject on the bucket's renders/* prefix; the bucketName or region passed to PHPClient does not match the render's bucket; the bucket was deleted (NoSuchBucket); expired credentials; or a transient S3/network error during PutObject.

Common situations: Rendering with a privileged role but canceling from an ops tool that uses read-only credentials; hand-typed bucket names that differ from the one in the render response; bucket policies that restrict writes to specific principals; cross-region S3 calls failing.

Related errors


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