Skip to content

🎥 Make videos programmatically with React

Cleanup resolved-props/[render-id].json in Lambda folder

Jonny Burger4ea1edc0f932
diff --git a/packages/lambda/src/functions/launch.ts b/packages/lambda/src/functions/launch.ts
index df12e9ad25..48b2b878fa 100644
--- a/packages/lambda/src/functions/launch.ts
+++ b/packages/lambda/src/functions/launch.ts
@@ -5,7 +5,10 @@ import {join} from 'node:path';
import {Internals} from 'remotion';
import {VERSION} from 'remotion/version';
import {getLambdaClient} from '../shared/aws-clients';
-import {cleanupSerializedInputProps} from '../shared/cleanup-serialized-input-props';
+import {
+ cleanupSerializedInputProps,
+ cleanupSerializedResolvedProps,
+} from '../shared/cleanup-serialized-input-props';
import {
compressInputProps,
decompressInputProps,
@@ -579,6 +582,11 @@ const innerLaunchHandler = async (params: LambdaPayload, options: Options) => {
region: getCurrentRegionInFunction(),
serialized: params.inputProps,
});
+ const cleanupResolvedInputPropsProm = cleanupSerializedResolvedProps({
+ bucketName: params.bucketName,
+ region: getCurrentRegionInFunction(),
+ serialized: serializedResolvedProps,
+ });
const outputUrl = getOutputUrlFromMetadata(
renderMetadata,
@@ -595,7 +603,11 @@ const innerLaunchHandler = async (params: LambdaPayload, options: Options) => {
errorExplanations: await errorExplanationsProm,
timeToEncode: encodingStop - encodingStart,
timeToDelete: (
- await Promise.all([deletProm, cleanupSerializedInputPropsProm])
+ await Promise.all([
+ deletProm,
+ cleanupSerializedInputPropsProm,
+ cleanupResolvedInputPropsProm,
+ ])
).reduce((a, b) => a + b, 0),
outputFile: {
lastModified: Date.now(),
diff --git a/packages/lambda/src/shared/cleanup-serialized-input-props.ts b/packages/lambda/src/shared/cleanup-serialized-input-props.ts
index 1be169dc91..d1ffc2fbc6 100644
--- a/packages/lambda/src/shared/cleanup-serialized-input-props.ts
+++ b/packages/lambda/src/shared/cleanup-serialized-input-props.ts
@@ -1,7 +1,7 @@
import type {AwsRegion} from '../client';
import {lambdaDeleteFile} from '../functions/helpers/io';
import type {SerializedInputProps} from './constants';
-import {inputPropsKey} from './constants';
+import {inputPropsKey, resolvedPropsKey} from './constants';
export const cleanupSerializedInputProps = async ({
serialized,
@@ -26,3 +26,27 @@ export const cleanupSerializedInputProps = async ({
return Date.now() - time;
};
+
+export const cleanupSerializedResolvedProps = async ({
+ serialized,
+ region,
+ bucketName,
+}: {
+ serialized: SerializedInputProps;
+ region: AwsRegion;
+ bucketName: string;
+}): Promise<number> => {
+ if (serialized.type === 'payload') {
+ return 0;
+ }
+
+ const time = Date.now();
+ await lambdaDeleteFile({
+ bucketName,
+ key: resolvedPropsKey(serialized.hash),
+ region,
+ customCredentials: null,
+ });
+
+ return Date.now() - time;
+};