remotion-dev/remotion · error · AggregateError
Deploying the site failed, and removing the generated bundle
Error message
Deploying the site failed, and removing the generated bundle also failed.
What it means
When deploySite() fails to upload the bundle to S3 and the subsequent cleanup (fs.rmSync of the generated bundle directory) also fails, Remotion throws an AggregateError wrapping both the deployment error and the cleanup error. This ensures the original failure is not masked and the cleanup failure is surfaced. If cleanup succeeds, only the original deployment error is thrown.
Source
Thrown at packages/lambda/src/api/deploy-site.ts:152
}
let cleanupFailed = false;
let cleanupError: unknown;
if (generatedBundleDir !== null) {
try {
fs.rmSync(generatedBundleDir, {
force: true,
recursive: true,
});
} catch (error) {
cleanupFailed = true;
cleanupError = error;
}
}
if (deploymentOutcome.type === 'failure') {
if (cleanupFailed) {
throw new AggregateError(
[deploymentOutcome.error, cleanupError],
'Deploying the site failed, and removing the generated bundle also failed.',
{cause: deploymentOutcome.error},
);
}
throw deploymentOutcome.error;
}
if (cleanupFailed) {
throw cleanupError;
}
return deploymentOutcome.result;
};
export type InternalDeploySiteInput = MandatoryParameters &
OptionalParameters & {View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Inspect the AggregateError.errors array — the first element is the original deployment failure (fix that first), the second is the cleanup failure.
- Fix the S3/CloudFront deployment issue (credentials, bucket name, permissions) that caused the upload to fail.
- Manually remove the generated bundle directory if cleanup failed, then retry deploySite().
- Ensure the temp directory used for bundle generation is writable and deletable by the process.
Defensive patterns
Strategy: try-catch
Type guard
function isAggregateError(err: unknown): err is AggregateError {
return err instanceof AggregateError || (err instanceof Error && Array.isArray((err as any).errors));
} Try / catch
try {
await deploySite({region, ...});
} catch (err) {
if (err instanceof AggregateError) {
const [deployError, cleanupError] = err.errors;
console.error('Deploy failed:', deployError);
console.error('Cleanup also failed:', cleanupError);
// Manually clean up the bundle dir if possible, then retry deploySite()
}
throw err;
} Prevention
- Verify S3 upload permissions before deploySite() to prevent the primary failure.
- Ensure the temp directory is writable and not locked by another process.
- Run deploySite() with sufficient disk space for the bundle.
- If using a CI runner, confirm it has permissions to create and delete files in its temp dir.
When it happens
Trigger: Calling deploySite() where the S3 upload step fails (network, permissions, bucket issue) AND the code that tries to delete the temporary generated bundle directory on disk also throws (permissions, file lock, already removed).
Common situations: S3 permissions insufficient for the upload while a file lock or permission issue prevents deleting the temp bundle; disk full during upload causing both upload failure and cleanup failure; running in a restricted container where both S3 access and temp file deletion are blocked.
Related errors
- You have multiple buckets ({', '.join(buckets)}) in your S3
- Lambda Insights is not supported by AWS in region ${region}.
- Lambda was created but has no name
- No bucket with the name ${bucketName} exists
- `throwIfSiteExists` was passed as true, but there are alread
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/123426cd7287c3d4.
Report an issue: GitHub.