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
- Unwrap the cause: inspect $exception->getPrevious() - the AWS error code (AccessDenied, NoSuchBucket, InvalidAccessKeyId, SlowDown) identifies the real problem.
- Grant s3:PutObject on arn:aws:s3:::<bucket>/renders/* to the IAM user or role the PHP client runs with.
- Verify the bucket name and region passed to PHPClient exactly match the values from the render response.
- 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
- Run the PHP client with credentials that have s3:GetObject + s3:PutObject on the bucket's renders/* prefix - the same surface the render itself uses.
- Take bucketName from the render response and reuse it for cancel; never retype it.
- Always log getPrevious() of the wrapped exception so AWS root causes are not lost.
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
- Could not read progress for render {$renderId}: {$exception-
- Cannot cancel render {$renderId}: The render was not started
- Could not cancel render {render_id}: {error}
- Error serializing inputProps. Check it has no circular refer
- could not read progress for render %q: %w
AI-assisted analysis of remotion-dev/remotion@10db9de073 (2026-08-22).
Data as JSON: /api/errors/814740cc34b712cf.
Report an issue: GitHub.