Skip to content

🎥 Make videos programmatically with React

`@remotion/lambda`: Test that the launch handler cleans up props on timeout

parbhatkapila49c588a76181d
diff --git a/packages/lambda/src/test/unit/output-access-error-identity.test.ts b/packages/lambda/src/test/unit/output-access-error-identity.test.ts
index 5a26aeb66e..e5b63d9010 100644
--- a/packages/lambda/src/test/unit/output-access-error-identity.test.ts
+++ b/packages/lambda/src/test/unit/output-access-error-identity.test.ts
@@ -24,6 +24,7 @@ import {VERSION} from 'remotion/version';
import * as headFileModule from '../../../../lambda-client/src/head-file';
import * as readFileModule from '../../../../lambda-client/src/read-file';
import * as writeFileModule from '../../../../lambda-client/src/write-file';
+import * as cleanupPropsModule from '../../functions/cleanup-props';
import * as browserInstance from '../../functions/get-browser-instance';
import {launchHandler} from '../../functions/handlers/launch';
import {progressHandler} from '../../functions/handlers/progress';
@@ -506,3 +507,54 @@ test('packaged status preserves unrelated storage failures and name-only lookali
await expect(invokeProgress(fixture)).rejects.toBe(error);
}
});
+
+test('launch cleans up the serialized props when it is about to time out', async () => {
+ makeFixture(new Error('Not called with overwrite'));
+ const cleanup = spyOn(cleanupPropsModule, 'cleanupProps').mockResolvedValue([
+ 0, 0,
+ ]);
+ const select = spyOn(
+ RenderInternals,
+ 'internalSelectComposition',
+ ).mockResolvedValue({
+ metadata: {
+ id: 'comp',
+ width: 100,
+ height: 100,
+ fps: 30,
+ durationInFrames: 20,
+ props: {},
+ },
+ } as never);
+ const render = spyOn(
+ directRenderer,
+ 'renderWithSingleFunction',
+ ).mockImplementation(() => new Promise(() => undefined) as never);
+ try {
+ launchHandler({
+ params: {...params, overwrite: true},
+ options: {
+ expectedBucketOwner: null,
+ getRemainingTimeInMillis: () => 0,
+ requestContext: {
+ requestId: 'test',
+ expectedBucketOwner: null,
+ getRemainingTimeInMillis: () => 0,
+ },
+ },
+ });
+ const start = Date.now();
+ while (cleanup.mock.calls.length === 0 && Date.now() - start < 3000) {
+ await new Promise((resolve) => {
+ setTimeout(resolve, 50);
+ });
+ }
+
+ expect(render).toHaveBeenCalledTimes(1);
+ expect(cleanup).toHaveBeenCalledTimes(1);
+ } finally {
+ cleanup.mockRestore();
+ select.mockRestore();
+ render.mockRestore();
+ }
+});