@remotion/lambda 4.0.167 → 4.0.169
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/deploy-site.d.ts +3 -3
- package/dist/api/render-still-on-lambda.js +1 -1
- package/dist/functions/helpers/cleanup-props.d.ts +5 -0
- package/dist/functions/helpers/cleanup-props.js +20 -0
- package/dist/functions/helpers/merge-chunks.js +5 -14
- package/dist/functions/helpers/streamify-response.d.ts +14 -7
- package/dist/functions/helpers/streamify-response.js +41 -29
- package/dist/functions/index.d.ts +4 -0
- package/dist/functions/index.js +3 -2
- package/dist/functions/launch.js +20 -1
- package/dist/functions/still.js +0 -1
- package/dist/internals.d.ts +5 -5
- package/dist/shared/aws-clients.js +13 -8
- package/dist/shared/call-lambda.js +28 -3
- package/dist/shared/cleanup-serialized-input-props.d.ts +2 -4
- package/dist/shared/cleanup-serialized-input-props.js +4 -4
- package/dist/shared/compress-props.js +1 -0
- package/dist/shared/constants.d.ts +1 -1
- package/dist/shared/constants.js +1 -5
- package/package.json +9 -9
- package/remotionlambda-arm64.zip +0 -0
- package/dist/functions/helpers/check-if-render-exists.d.ts +0 -3
- package/dist/functions/helpers/check-if-render-exists.js +0 -15
- package/dist/functions/helpers/delete-chunks.d.ts +0 -9
- package/dist/functions/helpers/delete-chunks.js +0 -25
- package/dist/functions/helpers/get-cleanup-progress.d.ts +0 -10
- package/dist/functions/helpers/get-cleanup-progress.js +0 -35
- package/dist/functions/helpers/get-encoding-metadata.d.ts +0 -7
- package/dist/functions/helpers/get-encoding-metadata.js +0 -15
- package/dist/functions/helpers/get-encoding-progress-step-size.d.ts +0 -1
- package/dist/functions/helpers/get-encoding-progress-step-size.js +0 -4
- package/dist/functions/helpers/get-files-to-delete.d.ts +0 -10
- package/dist/functions/helpers/get-files-to-delete.js +0 -52
- package/dist/functions/helpers/get-final-encoding-status.d.ts +0 -6
- package/dist/functions/helpers/get-final-encoding-status.js +0 -18
- package/dist/functions/helpers/get-folder-size.d.ts +0 -1
- package/dist/functions/helpers/get-folder-size.js +0 -8
- package/dist/functions/helpers/get-lambdas-invoked-stats.d.ts +0 -3
- package/dist/functions/helpers/get-lambdas-invoked-stats.js +0 -1
- package/dist/functions/helpers/get-post-render-data.d.ts +0 -8
- package/dist/functions/helpers/get-post-render-data.js +0 -22
- package/dist/functions/helpers/get-render-metadata.d.ts +0 -8
- package/dist/functions/helpers/get-render-metadata.js +0 -17
- package/dist/functions/helpers/get-rendered-frames-progress.d.ts +0 -8
- package/dist/functions/helpers/get-rendered-frames-progress.js +0 -37
- package/dist/functions/helpers/get-time-to-finish.d.ts +0 -5
- package/dist/functions/helpers/get-time-to-finish.js +0 -13
- package/dist/functions/helpers/streaming-payloads.d.ts +0 -19
- package/dist/functions/helpers/streaming-payloads.js +0 -25
- package/dist/functions/helpers/write-post-render-data.d.ts +0 -9
- package/dist/functions/helpers/write-post-render-data.js +0 -18
- package/dist/functions/merge.d.ts +0 -9
- package/dist/functions/merge.js +0 -61
- package/dist/shared/chunk-progress.d.ts +0 -9
- package/dist/shared/chunk-progress.js +0 -2034
- package/dist/shared/parse-chunk-key.d.ts +0 -5
- package/dist/shared/parse-chunk-key.js +0 -15
- package/dist/shared/parse-lambda-initialized-key.d.ts +0 -5
- package/dist/shared/parse-lambda-initialized-key.js +0 -15
|
@@ -59,11 +59,11 @@ export declare const internalDeploySite: (args_0: MandatoryParameters & {
|
|
|
59
59
|
getValue: ({ commandLine }: {
|
|
60
60
|
commandLine: Record<string, unknown>;
|
|
61
61
|
}) => {
|
|
62
|
-
value: "
|
|
62
|
+
value: "verbose" | "info" | "warn" | "error";
|
|
63
63
|
source: string;
|
|
64
64
|
};
|
|
65
|
-
setConfig: (newLogLevel: "
|
|
66
|
-
type: "
|
|
65
|
+
setConfig: (newLogLevel: "verbose" | "info" | "warn" | "error") => void;
|
|
66
|
+
type: "verbose" | "info" | "warn" | "error";
|
|
67
67
|
};
|
|
68
68
|
readonly throwIfSiteExists: {
|
|
69
69
|
cliFlag: string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cleanupProps = void 0;
|
|
4
|
+
const cleanup_serialized_input_props_1 = require("../../shared/cleanup-serialized-input-props");
|
|
5
|
+
const get_current_region_1 = require("./get-current-region");
|
|
6
|
+
const cleanupProps = ({ serializedResolvedProps, inputProps, }) => {
|
|
7
|
+
const cleanupSerializedInputPropsProm = (0, cleanup_serialized_input_props_1.cleanupSerializedInputProps)({
|
|
8
|
+
region: (0, get_current_region_1.getCurrentRegionInFunction)(),
|
|
9
|
+
serialized: inputProps,
|
|
10
|
+
});
|
|
11
|
+
const cleanupResolvedInputPropsProm = (0, cleanup_serialized_input_props_1.cleanupSerializedResolvedProps)({
|
|
12
|
+
region: (0, get_current_region_1.getCurrentRegionInFunction)(),
|
|
13
|
+
serialized: serializedResolvedProps,
|
|
14
|
+
});
|
|
15
|
+
return Promise.all([
|
|
16
|
+
cleanupSerializedInputPropsProm,
|
|
17
|
+
cleanupResolvedInputPropsProm,
|
|
18
|
+
]);
|
|
19
|
+
};
|
|
20
|
+
exports.cleanupProps = cleanupProps;
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.mergeChunksAndFinishRender = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const
|
|
8
|
+
const cleanup_props_1 = require("./cleanup-props");
|
|
9
9
|
const concat_videos_1 = require("./concat-videos");
|
|
10
10
|
const create_post_render_data_1 = require("./create-post-render-data");
|
|
11
11
|
const get_current_region_1 = require("./get-current-region");
|
|
@@ -56,15 +56,9 @@ const mergeChunksAndFinishRender = async (options) => {
|
|
|
56
56
|
const errorExplanations = (0, inspect_errors_1.inspectErrors)({
|
|
57
57
|
errors: options.overallProgress.get().errors,
|
|
58
58
|
});
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
serialized: options.inputProps,
|
|
63
|
-
});
|
|
64
|
-
const cleanupResolvedInputPropsProm = (0, cleanup_serialized_input_props_1.cleanupSerializedResolvedProps)({
|
|
65
|
-
bucketName: options.bucketName,
|
|
66
|
-
region: (0, get_current_region_1.getCurrentRegionInFunction)(),
|
|
67
|
-
serialized: options.serializedResolvedProps,
|
|
59
|
+
const cleanupProm = (0, cleanup_props_1.cleanupProps)({
|
|
60
|
+
inputProps: options.inputProps,
|
|
61
|
+
serializedResolvedProps: options.serializedResolvedProps,
|
|
68
62
|
});
|
|
69
63
|
const { url: outputUrl } = (0, get_output_url_from_metadata_1.getOutputUrlFromMetadata)(options.renderMetadata, options.bucketName, options.customCredentials);
|
|
70
64
|
const postRenderData = (0, create_post_render_data_1.createPostRenderData)({
|
|
@@ -72,10 +66,7 @@ const mergeChunksAndFinishRender = async (options) => {
|
|
|
72
66
|
memorySizeInMb: Number(process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE),
|
|
73
67
|
renderMetadata: options.renderMetadata,
|
|
74
68
|
errorExplanations,
|
|
75
|
-
timeToDelete: (await
|
|
76
|
-
cleanupSerializedInputPropsProm,
|
|
77
|
-
cleanupResolvedInputPropsProm,
|
|
78
|
-
])).reduce((a, b) => Math.max(a, b), 0),
|
|
69
|
+
timeToDelete: (await cleanupProm).reduce((a, b) => Math.max(a, b), 0),
|
|
79
70
|
outputFile: {
|
|
80
71
|
url: outputUrl,
|
|
81
72
|
},
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { Writable } from 'stream';
|
|
4
|
+
type Chunk = {
|
|
5
|
+
PayloadChunk: {
|
|
6
|
+
Payload: string | Buffer | null;
|
|
7
|
+
};
|
|
8
|
+
InvokeComplete: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare class ResponseStream extends Writable {
|
|
11
|
+
private queue;
|
|
12
|
+
private waitingResolve;
|
|
5
13
|
private response;
|
|
6
|
-
_contentType?: string;
|
|
7
|
-
_isBase64Encoded?: boolean;
|
|
8
14
|
constructor();
|
|
9
|
-
_write(chunk:
|
|
15
|
+
_write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
16
|
+
_finish(): void;
|
|
10
17
|
getBufferedData(): Buffer;
|
|
11
|
-
|
|
12
|
-
setIsBase64Encoded(isBase64Encoded: boolean): void;
|
|
18
|
+
[Symbol.asyncIterator](): AsyncGenerator<Chunk, void, void>;
|
|
13
19
|
}
|
|
14
20
|
export declare function streamifyResponse(handler: Function): Function;
|
|
21
|
+
export {};
|
|
@@ -2,33 +2,58 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.streamifyResponse = exports.ResponseStream = void 0;
|
|
4
4
|
const stream_1 = require("stream");
|
|
5
|
-
class ResponseStream extends stream_1.
|
|
5
|
+
class ResponseStream extends stream_1.Writable {
|
|
6
6
|
constructor() {
|
|
7
7
|
super();
|
|
8
|
+
this.queue = [];
|
|
9
|
+
this.waitingResolve = [];
|
|
8
10
|
this.response = [];
|
|
9
11
|
}
|
|
10
12
|
_write(chunk, encoding, callback) {
|
|
13
|
+
const data = Buffer.from(chunk, encoding);
|
|
14
|
+
const resolve = this.waitingResolve.shift();
|
|
15
|
+
if (resolve) {
|
|
16
|
+
resolve({ PayloadChunk: { Payload: data }, InvokeComplete: false });
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
this.queue.push({ PayloadChunk: { Payload: data }, InvokeComplete: false });
|
|
20
|
+
}
|
|
11
21
|
this.response.push(Buffer.from(chunk, encoding));
|
|
12
22
|
callback();
|
|
13
23
|
}
|
|
24
|
+
_finish() {
|
|
25
|
+
const resolve = this.waitingResolve.shift();
|
|
26
|
+
if (resolve) {
|
|
27
|
+
resolve({ PayloadChunk: { Payload: null }, InvokeComplete: true });
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
this.queue.push({ PayloadChunk: { Payload: null }, InvokeComplete: true });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
14
33
|
getBufferedData() {
|
|
15
34
|
return Buffer.concat(this.response);
|
|
16
35
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
36
|
+
async *[Symbol.asyncIterator]() {
|
|
37
|
+
while (true) {
|
|
38
|
+
if (this.queue.length > 0) {
|
|
39
|
+
yield this.queue.shift();
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// Wait for new data to be written
|
|
43
|
+
yield new Promise((resolve) => {
|
|
44
|
+
this.waitingResolve.push((data) => {
|
|
45
|
+
Promise.resolve(data).then((d) => {
|
|
46
|
+
if (d) {
|
|
47
|
+
resolve(d);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
22
54
|
}
|
|
23
55
|
}
|
|
24
56
|
exports.ResponseStream = ResponseStream;
|
|
25
|
-
function patchArgs(argList) {
|
|
26
|
-
if (!(argList[1] instanceof ResponseStream)) {
|
|
27
|
-
const responseStream = new ResponseStream();
|
|
28
|
-
argList.splice(1, 0, responseStream);
|
|
29
|
-
}
|
|
30
|
-
return argList[1];
|
|
31
|
-
}
|
|
32
57
|
function streamifyResponse(handler) {
|
|
33
58
|
// Check if we are inside Lambda
|
|
34
59
|
if (process.env.AWS_LAMBDA_FUNCTION_VERSION &&
|
|
@@ -38,21 +63,8 @@ function streamifyResponse(handler) {
|
|
|
38
63
|
// @ts-expect-error
|
|
39
64
|
return awslambda.streamifyResponse(handler);
|
|
40
65
|
}
|
|
41
|
-
return
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
await target(...argList);
|
|
45
|
-
return {
|
|
46
|
-
EventStream: [
|
|
47
|
-
{
|
|
48
|
-
PayloadChunk: {
|
|
49
|
-
Payload: responseStream.getBufferedData(),
|
|
50
|
-
},
|
|
51
|
-
InvokeComplete: true,
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
};
|
|
55
|
-
},
|
|
56
|
-
});
|
|
66
|
+
return () => {
|
|
67
|
+
throw new Error('Lambda not detected');
|
|
68
|
+
};
|
|
57
69
|
}
|
|
58
70
|
exports.streamifyResponse = streamifyResponse;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import type { LambdaPayload } from '../shared/constants';
|
|
2
|
+
import type { RequestContext } from './helpers/request-context';
|
|
3
|
+
import type { ResponseStream } from './helpers/streamify-response';
|
|
1
4
|
export type OrError<T> = T | {
|
|
2
5
|
type: 'error';
|
|
3
6
|
message: string;
|
|
4
7
|
stack: string;
|
|
5
8
|
};
|
|
9
|
+
export declare const routine: (params: LambdaPayload, responseStream: ResponseStream, context: RequestContext) => Promise<void>;
|
|
6
10
|
export declare const handler: Function;
|
package/dist/functions/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.handler = void 0;
|
|
3
|
+
exports.handler = exports.routine = void 0;
|
|
4
4
|
const renderer_1 = require("@remotion/renderer");
|
|
5
5
|
const constants_1 = require("../shared/constants");
|
|
6
6
|
const compositions_1 = require("./compositions");
|
|
@@ -183,4 +183,5 @@ const routine = async (params, responseStream, context) => {
|
|
|
183
183
|
await responseWriter.end();
|
|
184
184
|
}
|
|
185
185
|
};
|
|
186
|
-
exports.
|
|
186
|
+
exports.routine = routine;
|
|
187
|
+
exports.handler = (0, streamify_response_1.streamifyResponse)(exports.routine);
|
package/dist/functions/launch.js
CHANGED
|
@@ -15,6 +15,7 @@ const validate_outname_1 = require("../shared/validate-outname");
|
|
|
15
15
|
const validate_privacy_1 = require("../shared/validate-privacy");
|
|
16
16
|
const plan_frame_ranges_1 = require("./chunk-optimization/plan-frame-ranges");
|
|
17
17
|
const best_frames_per_lambda_param_1 = require("./helpers/best-frames-per-lambda-param");
|
|
18
|
+
const cleanup_props_1 = require("./helpers/cleanup-props");
|
|
18
19
|
const expected_out_name_1 = require("./helpers/expected-out-name");
|
|
19
20
|
const find_output_file_in_bucket_1 = require("./helpers/find-output-file-in-bucket");
|
|
20
21
|
const get_browser_instance_1 = require("./helpers/get-browser-instance");
|
|
@@ -24,7 +25,7 @@ const overall_render_progress_1 = require("./helpers/overall-render-progress");
|
|
|
24
25
|
const stream_renderer_1 = require("./helpers/stream-renderer");
|
|
25
26
|
const validate_composition_1 = require("./helpers/validate-composition");
|
|
26
27
|
const write_lambda_error_1 = require("./helpers/write-lambda-error");
|
|
27
|
-
const innerLaunchHandler = async ({ functionName, params, options, overallProgress, }) => {
|
|
28
|
+
const innerLaunchHandler = async ({ functionName, params, options, overallProgress, registerCleanupTask, }) => {
|
|
28
29
|
var _a, _b, _c, _d, _e;
|
|
29
30
|
if (params.type !== constants_1.LambdaRoutines.launch) {
|
|
30
31
|
throw new Error('Expected launch type');
|
|
@@ -119,6 +120,12 @@ const innerLaunchHandler = async ({ functionName, params, options, overallProgre
|
|
|
119
120
|
userSpecifiedBucketName: params.bucketName,
|
|
120
121
|
needsToUpload,
|
|
121
122
|
});
|
|
123
|
+
registerCleanupTask(() => {
|
|
124
|
+
return (0, cleanup_props_1.cleanupProps)({
|
|
125
|
+
serializedResolvedProps,
|
|
126
|
+
inputProps: params.inputProps,
|
|
127
|
+
});
|
|
128
|
+
});
|
|
122
129
|
const fps = comp.fps / params.everyNthFrame;
|
|
123
130
|
// If for 150 functions, we stream every frame, we DDos ourselves.
|
|
124
131
|
// Throttling a bit, allowing more progress if there is lower concurrency.
|
|
@@ -282,6 +289,10 @@ const launchHandler = async (params, options) => {
|
|
|
282
289
|
indent: false,
|
|
283
290
|
logLevel: params.logLevel,
|
|
284
291
|
};
|
|
292
|
+
const cleanupTasks = [];
|
|
293
|
+
const registerCleanupTask = (task) => {
|
|
294
|
+
cleanupTasks.push(task);
|
|
295
|
+
};
|
|
285
296
|
const onTimeout = async () => {
|
|
286
297
|
var _a;
|
|
287
298
|
renderer_1.RenderInternals.Log.error({ indent: false, logLevel: params.logLevel }, 'Function is about to time out. Can not finish render.');
|
|
@@ -291,6 +302,13 @@ const launchHandler = async (params, options) => {
|
|
|
291
302
|
if (webhookInvoked) {
|
|
292
303
|
return;
|
|
293
304
|
}
|
|
305
|
+
Promise.all(cleanupTasks)
|
|
306
|
+
.then(() => {
|
|
307
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel: params.logLevel }, 'Ran cleanup tasks');
|
|
308
|
+
})
|
|
309
|
+
.catch((err) => {
|
|
310
|
+
renderer_1.RenderInternals.Log.error({ indent: false, logLevel: params.logLevel }, 'Failed to run cleanup tasks:', err);
|
|
311
|
+
});
|
|
294
312
|
try {
|
|
295
313
|
await (0, invoke_webhook_1.invokeWebhook)({
|
|
296
314
|
url: params.webhook.url,
|
|
@@ -345,6 +363,7 @@ const launchHandler = async (params, options) => {
|
|
|
345
363
|
params,
|
|
346
364
|
options,
|
|
347
365
|
overallProgress,
|
|
366
|
+
registerCleanupTask,
|
|
348
367
|
});
|
|
349
368
|
clearTimeout(webhookDueToTimeout);
|
|
350
369
|
if (!params.webhook || webhookInvoked) {
|
package/dist/functions/still.js
CHANGED
|
@@ -191,7 +191,6 @@ const innerStillHandler = async ({ params: lambdaParams, expectedBucketOwner, re
|
|
|
191
191
|
await Promise.all([
|
|
192
192
|
node_fs_1.default.promises.rm(outputPath, { recursive: true }),
|
|
193
193
|
(0, cleanup_serialized_input_props_1.cleanupSerializedInputProps)({
|
|
194
|
-
bucketName,
|
|
195
194
|
region: (0, get_current_region_1.getCurrentRegionInFunction)(),
|
|
196
195
|
serialized: lambdaParams.inputProps,
|
|
197
196
|
}),
|
package/dist/internals.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const LambdaInternals: {
|
|
2
|
-
executeCommand: (args: string[], remotionRoot: string, logLevel: "
|
|
2
|
+
executeCommand: (args: string[], remotionRoot: string, logLevel: "verbose" | "info" | "warn" | "error") => Promise<void>;
|
|
3
3
|
makeLambdaRenderMediaPayload: ({ rendererFunctionName, frameRange, framesPerLambda, forceBucketName: bucketName, codec, composition, serveUrl, imageFormat, inputProps, region, crf, envVariables, pixelFormat, proResProfile, x264Preset, maxRetries, privacy, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, everyNthFrame, numberOfGifLoops, audioBitrate, concurrencyPerLambda, audioCodec, forceHeight, forceWidth, webhook, videoBitrate, encodingMaxRate, encodingBufferSize, downloadBehavior, muted, overwrite, jpegQuality, offthreadVideoCacheSizeInBytes, deleteAfter, colorSpace, preferLossless, }: import("./api/make-lambda-payload").InnerRenderMediaOnLambdaInput) => Promise<import("./defaults").LambdaStartPayload>;
|
|
4
4
|
getRenderProgressPayload: ({ bucketName, renderId, s3OutputProvider, logLevel, }: import("./client").GetRenderProgressInput) => import("./defaults").LambdaStatusPayload;
|
|
5
5
|
makeLambdaRenderStillPayload: ({ serveUrl, inputProps, imageFormat, envVariables, quality, jpegQuality, region, maxRetries, composition, privacy, frame, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, downloadBehavior, forceHeight, forceWidth, forceBucketName, offthreadVideoCacheSizeInBytes, deleteAfter, }: import("./api/render-still-on-lambda").RenderStillOnLambdaNonNullInput) => Promise<{
|
|
@@ -14,7 +14,7 @@ export declare const LambdaInternals: {
|
|
|
14
14
|
maxRetries: number;
|
|
15
15
|
frame: number;
|
|
16
16
|
privacy: import("./defaults").Privacy;
|
|
17
|
-
logLevel: "
|
|
17
|
+
logLevel: "verbose" | "info" | "warn" | "error";
|
|
18
18
|
outName: import("./defaults").OutNameInput | null;
|
|
19
19
|
timeoutInMilliseconds: number;
|
|
20
20
|
chromiumOptions: import("@remotion/renderer").ChromiumOptions;
|
|
@@ -57,11 +57,11 @@ export declare const LambdaInternals: {
|
|
|
57
57
|
getValue: ({ commandLine }: {
|
|
58
58
|
commandLine: Record<string, unknown>;
|
|
59
59
|
}) => {
|
|
60
|
-
value: "
|
|
60
|
+
value: "verbose" | "info" | "warn" | "error";
|
|
61
61
|
source: string;
|
|
62
62
|
};
|
|
63
|
-
setConfig: (newLogLevel: "
|
|
64
|
-
type: "
|
|
63
|
+
setConfig: (newLogLevel: "verbose" | "info" | "warn" | "error") => void;
|
|
64
|
+
type: "verbose" | "info" | "warn" | "error";
|
|
65
65
|
};
|
|
66
66
|
readonly throwIfSiteExists: {
|
|
67
67
|
cliFlag: string;
|
|
@@ -126,6 +126,13 @@ const getServiceClient = ({ region, service, customCredentials, }) => {
|
|
|
126
126
|
});
|
|
127
127
|
if (!_clients[key]) {
|
|
128
128
|
(0, check_credentials_1.checkCredentials)();
|
|
129
|
+
const lambdaOptions = service === 'lambda'
|
|
130
|
+
? {
|
|
131
|
+
httpsAgent: {
|
|
132
|
+
maxSockets: constants_1.MAX_FUNCTIONS_PER_RENDER * 2,
|
|
133
|
+
},
|
|
134
|
+
}
|
|
135
|
+
: undefined;
|
|
129
136
|
const client = customCredentials
|
|
130
137
|
? new Client({
|
|
131
138
|
region: (_a = customCredentials.region) !== null && _a !== void 0 ? _a : 'us-east-1',
|
|
@@ -136,19 +143,17 @@ const getServiceClient = ({ region, service, customCredentials, }) => {
|
|
|
136
143
|
}
|
|
137
144
|
: undefined,
|
|
138
145
|
endpoint: customCredentials.endpoint,
|
|
146
|
+
requestHandler: lambdaOptions,
|
|
139
147
|
})
|
|
140
148
|
: process.env.REMOTION_SKIP_AWS_CREDENTIALS_CHECK
|
|
141
|
-
? new Client({
|
|
149
|
+
? new Client({
|
|
150
|
+
region,
|
|
151
|
+
requestHandler: lambdaOptions,
|
|
152
|
+
})
|
|
142
153
|
: new Client({
|
|
143
154
|
region,
|
|
144
155
|
credentials: getCredentials(),
|
|
145
|
-
requestHandler:
|
|
146
|
-
? {
|
|
147
|
-
httpsAgent: {
|
|
148
|
-
maxSockets: constants_1.MAX_FUNCTIONS_PER_RENDER + 50,
|
|
149
|
-
},
|
|
150
|
-
}
|
|
151
|
-
: undefined,
|
|
156
|
+
requestHandler: lambdaOptions,
|
|
152
157
|
});
|
|
153
158
|
if (process.env.REMOTION_DISABLE_AWS_CLIENT_CACHE) {
|
|
154
159
|
return client;
|
|
@@ -37,7 +37,8 @@ const callLambdaWithStreaming = async (options) => {
|
|
|
37
37
|
if (options.retriesRemaining === 0) {
|
|
38
38
|
throw err;
|
|
39
39
|
}
|
|
40
|
-
if (!err.message.includes(INVALID_JSON_MESSAGE)
|
|
40
|
+
if (!err.message.includes(INVALID_JSON_MESSAGE) &&
|
|
41
|
+
!err.message.includes(LAMBDA_STREAM_STALL)) {
|
|
41
42
|
throw err;
|
|
42
43
|
}
|
|
43
44
|
return (0, exports.callLambdaWithStreaming)({
|
|
@@ -62,11 +63,34 @@ const callLambdaWithoutRetry = async ({ functionName, type, payload, region, tim
|
|
|
62
63
|
throw new Error(`Invalid JSON (${type}): ${JSON.stringify(decoded)}`);
|
|
63
64
|
}
|
|
64
65
|
};
|
|
65
|
-
const
|
|
66
|
-
|
|
66
|
+
const STREAM_STALL_TIMEOUT = 7000;
|
|
67
|
+
const LAMBDA_STREAM_STALL = `AWS did not invoke Lambda in ${STREAM_STALL_TIMEOUT}ms`;
|
|
68
|
+
const invokeStreamOrTimeout = async ({ region, timeoutInTest, functionName, type, payload, }) => {
|
|
69
|
+
const resProm = (0, aws_clients_1.getLambdaClient)(region, timeoutInTest).send(new client_lambda_1.InvokeWithResponseStreamCommand({
|
|
67
70
|
FunctionName: functionName,
|
|
68
71
|
Payload: JSON.stringify({ type, ...payload }),
|
|
69
72
|
}));
|
|
73
|
+
let cleanup = () => undefined;
|
|
74
|
+
const timeout = new Promise((_resolve, reject) => {
|
|
75
|
+
const int = setTimeout(() => {
|
|
76
|
+
reject(new Error(LAMBDA_STREAM_STALL));
|
|
77
|
+
}, STREAM_STALL_TIMEOUT);
|
|
78
|
+
cleanup = () => {
|
|
79
|
+
clearTimeout(int);
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
const res = await Promise.race([resProm, timeout]);
|
|
83
|
+
cleanup();
|
|
84
|
+
return res;
|
|
85
|
+
};
|
|
86
|
+
const callLambdaWithStreamingWithoutRetry = async ({ functionName, type, payload, region, timeoutInTest, receivedStreamingPayload, }) => {
|
|
87
|
+
const res = await invokeStreamOrTimeout({
|
|
88
|
+
functionName,
|
|
89
|
+
payload,
|
|
90
|
+
region,
|
|
91
|
+
timeoutInTest,
|
|
92
|
+
type,
|
|
93
|
+
});
|
|
70
94
|
const { onData, clear } = (0, streaming_1.makeStreamer)((status, messageTypeId, data) => {
|
|
71
95
|
const messageType = (0, streaming_2.messageTypeIdToMessageType)(messageTypeId);
|
|
72
96
|
const innerPayload = streaming_2.formatMap[messageType] === 'json'
|
|
@@ -97,6 +121,7 @@ const callLambdaWithStreamingWithoutRetry = async ({ functionName, type, payload
|
|
|
97
121
|
}
|
|
98
122
|
throw new Error(`Lambda function ${functionName} failed with error code ${event.InvokeComplete.ErrorCode}: ${event.InvokeComplete.ErrorDetails}. See ${logs} to see the logs of this invocation.`);
|
|
99
123
|
}
|
|
124
|
+
break;
|
|
100
125
|
}
|
|
101
126
|
}
|
|
102
127
|
clear();
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import type { AwsRegion } from '../client';
|
|
2
2
|
import type { SerializedInputProps } from './constants';
|
|
3
|
-
export declare const cleanupSerializedInputProps: ({ serialized, region,
|
|
3
|
+
export declare const cleanupSerializedInputProps: ({ serialized, region, }: {
|
|
4
4
|
serialized: SerializedInputProps;
|
|
5
5
|
region: AwsRegion;
|
|
6
|
-
bucketName: string;
|
|
7
6
|
}) => Promise<number>;
|
|
8
|
-
export declare const cleanupSerializedResolvedProps: ({ serialized, region,
|
|
7
|
+
export declare const cleanupSerializedResolvedProps: ({ serialized, region, }: {
|
|
9
8
|
serialized: SerializedInputProps;
|
|
10
9
|
region: AwsRegion;
|
|
11
|
-
bucketName: string;
|
|
12
10
|
}) => Promise<number>;
|
|
@@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.cleanupSerializedResolvedProps = exports.cleanupSerializedInputProps = void 0;
|
|
4
4
|
const io_1 = require("../functions/helpers/io");
|
|
5
5
|
const constants_1 = require("./constants");
|
|
6
|
-
const cleanupSerializedInputProps = async ({ serialized, region,
|
|
6
|
+
const cleanupSerializedInputProps = async ({ serialized, region, }) => {
|
|
7
7
|
if (serialized.type === 'payload') {
|
|
8
8
|
return 0;
|
|
9
9
|
}
|
|
10
10
|
const time = Date.now();
|
|
11
11
|
await (0, io_1.lambdaDeleteFile)({
|
|
12
|
-
bucketName,
|
|
12
|
+
bucketName: serialized.bucketName,
|
|
13
13
|
key: (0, constants_1.inputPropsKey)(serialized.hash),
|
|
14
14
|
region,
|
|
15
15
|
customCredentials: null,
|
|
@@ -17,13 +17,13 @@ const cleanupSerializedInputProps = async ({ serialized, region, bucketName, })
|
|
|
17
17
|
return Date.now() - time;
|
|
18
18
|
};
|
|
19
19
|
exports.cleanupSerializedInputProps = cleanupSerializedInputProps;
|
|
20
|
-
const cleanupSerializedResolvedProps = async ({ serialized, region,
|
|
20
|
+
const cleanupSerializedResolvedProps = async ({ serialized, region, }) => {
|
|
21
21
|
if (serialized.type === 'payload') {
|
|
22
22
|
return 0;
|
|
23
23
|
}
|
|
24
24
|
const time = Date.now();
|
|
25
25
|
await (0, io_1.lambdaDeleteFile)({
|
|
26
|
-
bucketName,
|
|
26
|
+
bucketName: serialized.bucketName,
|
|
27
27
|
key: (0, constants_1.resolvedPropsKey)(serialized.hash),
|
|
28
28
|
region,
|
|
29
29
|
customCredentials: null,
|
|
@@ -52,7 +52,6 @@ export declare const getSitesKey: (siteId: string) => string;
|
|
|
52
52
|
export declare const outName: (renderId: string, extension: string) => string;
|
|
53
53
|
export declare const outStillName: (renderId: string, imageFormat: StillImageFormat) => string;
|
|
54
54
|
export declare const customOutName: (renderId: string, bucketName: string, name: OutNameInput) => OutNameOutput;
|
|
55
|
-
export declare const defaultPropsKey: (hash: string) => string;
|
|
56
55
|
export declare const inputPropsKey: (hash: string) => string;
|
|
57
56
|
export declare const resolvedPropsKey: (hash: string) => string;
|
|
58
57
|
export declare const RENDERER_PATH_TOKEN = "remotion-bucket";
|
|
@@ -80,6 +79,7 @@ export type WebhookOption = Prettify<null | ({
|
|
|
80
79
|
export type SerializedInputProps = {
|
|
81
80
|
type: 'bucket-url';
|
|
82
81
|
hash: string;
|
|
82
|
+
bucketName: string;
|
|
83
83
|
} | {
|
|
84
84
|
type: 'payload';
|
|
85
85
|
payload: string;
|
package/dist/shared/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LAMBDA_CONCURRENCY_LIMIT_QUOTA = exports.LambdaRoutines = exports.REMOTION_FILELIST_TOKEN = exports.REMOTION_CONCATED_TOKEN = exports.CONCAT_FOLDER_TOKEN = exports.RENDERER_PATH_TOKEN = exports.resolvedPropsKey = exports.inputPropsKey = exports.
|
|
3
|
+
exports.LAMBDA_CONCURRENCY_LIMIT_QUOTA = exports.LambdaRoutines = exports.REMOTION_FILELIST_TOKEN = exports.REMOTION_CONCATED_TOKEN = exports.CONCAT_FOLDER_TOKEN = exports.RENDERER_PATH_TOKEN = exports.resolvedPropsKey = exports.inputPropsKey = exports.customOutName = exports.outStillName = exports.outName = exports.getSitesKey = exports.overallProgressKey = exports.rendersPrefix = exports.LAMBDA_INSIGHTS_PREFIX = exports.LOG_GROUP_PREFIX = exports.RENDER_FN_PREFIX = exports.REMOTION_BUCKET_PREFIX = exports.DEFAULT_CLOUDWATCH_RETENTION_PERIOD = exports.DEFAULT_OUTPUT_PRIVACY = exports.MAX_EPHEMERAL_STORAGE_IN_MB = exports.MIN_EPHEMERAL_STORAGE_IN_MB = exports.DEFAULT_EPHEMERAL_STORAGE_IN_MB = exports.MAX_FUNCTIONS_PER_RENDER = exports.DEFAULT_MAX_RETRIES = exports.DEFAULT_REGION = exports.COMMAND_NOT_FOUND = exports.BINARY_NAME = exports.DEFAULT_FRAMES_PER_LAMBDA = exports.MINIMUM_FRAMES_PER_LAMBDA = exports.MAX_TIMEOUT = exports.MIN_TIMEOUT = exports.DEFAULT_TIMEOUT = exports.DEFAULT_MEMORY_SIZE = exports.MAX_MEMORY = exports.MIN_MEMORY = void 0;
|
|
4
4
|
exports.MIN_MEMORY = 512;
|
|
5
5
|
exports.MAX_MEMORY = 10240;
|
|
6
6
|
exports.DEFAULT_MEMORY_SIZE = 2048;
|
|
@@ -49,10 +49,6 @@ const customOutName = (renderId, bucketName, name) => {
|
|
|
49
49
|
};
|
|
50
50
|
};
|
|
51
51
|
exports.customOutName = customOutName;
|
|
52
|
-
const defaultPropsKey = (hash) => {
|
|
53
|
-
return `default-props/${hash}.json`;
|
|
54
|
-
};
|
|
55
|
-
exports.defaultPropsKey = defaultPropsKey;
|
|
56
52
|
const inputPropsKey = (hash) => {
|
|
57
53
|
return `input-props/${hash}.json`;
|
|
58
54
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/lambda",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.169",
|
|
4
4
|
"description": "Distributed renderer for Remotion based on AWS Lambda",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"@aws-sdk/s3-request-presigner": "3.583.0",
|
|
23
23
|
"mime-types": "2.1.34",
|
|
24
24
|
"zod": "3.22.3",
|
|
25
|
-
"@remotion/bundler": "4.0.
|
|
26
|
-
"@remotion/
|
|
27
|
-
"@remotion/
|
|
28
|
-
"remotion": "4.0.
|
|
29
|
-
"
|
|
25
|
+
"@remotion/bundler": "4.0.169",
|
|
26
|
+
"@remotion/cli": "4.0.169",
|
|
27
|
+
"@remotion/renderer": "4.0.169",
|
|
28
|
+
"@remotion/streaming": "4.0.169",
|
|
29
|
+
"remotion": "4.0.169"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@jonny/eslint-config": "3.0.281",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"ts-node": "10.9.2",
|
|
43
43
|
"vitest": "0.31.1",
|
|
44
44
|
"zip-lib": "^0.7.2",
|
|
45
|
-
"@remotion/bundler": "4.0.
|
|
46
|
-
"@remotion/compositor-linux-arm64-gnu": "4.0.
|
|
45
|
+
"@remotion/bundler": "4.0.169",
|
|
46
|
+
"@remotion/compositor-linux-arm64-gnu": "4.0.169"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@remotion/bundler": "4.0.
|
|
49
|
+
"@remotion/bundler": "4.0.169"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
package/remotionlambda-arm64.zip
CHANGED
|
Binary file
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkIfRenderExists = void 0;
|
|
4
|
-
const constants_1 = require("../../shared/constants");
|
|
5
|
-
const checkIfRenderExists = (contents, renderId, bucketName, region) => {
|
|
6
|
-
const initializedExists = Boolean(contents.find((c) => {
|
|
7
|
-
var _a;
|
|
8
|
-
return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.initalizedMetadataKey)(renderId));
|
|
9
|
-
}));
|
|
10
|
-
if (!initializedExists) {
|
|
11
|
-
// ! Error message is checked in progress handler and will be retried. Make sure to update
|
|
12
|
-
throw new TypeError(`No render with ID "${renderId}" found in bucket ${bucketName} and region ${region}`);
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
exports.checkIfRenderExists = checkIfRenderExists;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { _Object } from '@aws-sdk/client-s3';
|
|
2
|
-
import type { AwsRegion } from '../../pricing/aws-regions';
|
|
3
|
-
import type { CleanupJob } from './get-files-to-delete';
|
|
4
|
-
export declare const cleanupFiles: ({ bucket, region, contents, jobs, }: {
|
|
5
|
-
bucket: string;
|
|
6
|
-
region: AwsRegion;
|
|
7
|
-
contents: _Object[];
|
|
8
|
-
jobs: CleanupJob[];
|
|
9
|
-
}) => Promise<number>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cleanupFiles = void 0;
|
|
4
|
-
const clean_items_1 = require("../../api/clean-items");
|
|
5
|
-
const cleanupFiles = async ({ bucket, region, contents, jobs, }) => {
|
|
6
|
-
const start = Date.now();
|
|
7
|
-
await (0, clean_items_1.cleanItems)({
|
|
8
|
-
bucket,
|
|
9
|
-
region,
|
|
10
|
-
list: jobs.map((item) => {
|
|
11
|
-
var _a;
|
|
12
|
-
if (item.type === 'exact') {
|
|
13
|
-
return item.name;
|
|
14
|
-
}
|
|
15
|
-
if (item.type === 'prefix') {
|
|
16
|
-
return (_a = contents.find((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith(item.name); })) === null || _a === void 0 ? void 0 : _a.Key;
|
|
17
|
-
}
|
|
18
|
-
throw new Error('unexpected in deleteChunks()');
|
|
19
|
-
}),
|
|
20
|
-
onAfterItemDeleted: () => undefined,
|
|
21
|
-
onBeforeItemDeleted: () => undefined,
|
|
22
|
-
});
|
|
23
|
-
return Date.now() - start;
|
|
24
|
-
};
|
|
25
|
-
exports.cleanupFiles = cleanupFiles;
|