@remotion/lambda 4.0.164 → 4.0.165
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/delete-render.js +7 -3
- package/dist/api/deploy-function.d.ts +0 -1
- package/dist/api/deploy-function.js +3 -3
- package/dist/api/download-media.js +6 -3
- package/dist/api/get-compositions-on-lambda.js +0 -2
- package/dist/api/get-render-progress.js +0 -2
- package/dist/api/make-lambda-payload.js +2 -1
- package/dist/api/render-media-on-lambda.js +0 -2
- package/dist/api/render-still-on-lambda.js +37 -25
- package/dist/cli/commands/render/progress.d.ts +3 -28
- package/dist/cli/commands/render/progress.js +89 -90
- package/dist/cli/commands/render/render.js +7 -40
- package/dist/cli/commands/sites/create.js +2 -2
- package/dist/functions/chunk-optimization/types.d.ts +0 -3
- package/dist/functions/helpers/calculate-chunk-times.d.ts +3 -4
- package/dist/functions/helpers/calculate-chunk-times.js +4 -8
- package/dist/functions/helpers/calculate-price-from-bucket.d.ts +3 -5
- package/dist/functions/helpers/calculate-price-from-bucket.js +5 -18
- package/dist/functions/helpers/clean-tmpdir.d.ts +0 -2
- package/dist/functions/helpers/clean-tmpdir.js +1 -7
- package/dist/functions/helpers/concat-videos.d.ts +1 -13
- package/dist/functions/helpers/concat-videos.js +7 -131
- package/dist/functions/helpers/create-post-render-data.d.ts +6 -6
- package/dist/functions/helpers/create-post-render-data.js +17 -37
- package/dist/functions/helpers/find-output-file-in-bucket.d.ts +1 -3
- package/dist/functions/helpers/find-output-file-in-bucket.js +1 -4
- package/dist/functions/helpers/get-encoding-progress-step-size.d.ts +1 -1
- package/dist/functions/helpers/get-encoding-progress-step-size.js +0 -3
- package/dist/functions/helpers/get-lambdas-invoked-stats.d.ts +1 -6
- package/dist/functions/helpers/get-lambdas-invoked-stats.js +0 -13
- package/dist/functions/helpers/get-overall-progress-s3.d.ts +4 -2
- package/dist/functions/helpers/get-overall-progress-s3.js +8 -6
- package/dist/functions/helpers/get-overall-progress.d.ts +1 -2
- package/dist/functions/helpers/get-overall-progress.js +2 -4
- package/dist/functions/helpers/get-progress.js +78 -154
- package/dist/functions/helpers/get-retry-stats.d.ts +0 -5
- package/dist/functions/helpers/get-retry-stats.js +0 -18
- package/dist/functions/helpers/inspect-errors.d.ts +4 -10
- package/dist/functions/helpers/inspect-errors.js +5 -27
- package/dist/functions/helpers/io.d.ts +0 -1
- package/dist/functions/helpers/io.js +2 -3
- package/dist/functions/helpers/lifecycle.d.ts +0 -4
- package/dist/functions/helpers/lifecycle.js +2 -3
- package/dist/functions/helpers/make-timeout-error.d.ts +0 -2
- package/dist/functions/helpers/merge-chunks.d.ts +5 -0
- package/dist/functions/helpers/merge-chunks.js +16 -143
- package/dist/functions/helpers/min-max.d.ts +1 -1
- package/dist/functions/helpers/min-max.js +1 -1
- package/dist/functions/helpers/overall-render-progress.d.ts +26 -4
- package/dist/functions/helpers/overall-render-progress.js +116 -27
- package/dist/functions/helpers/stream-renderer.js +15 -9
- package/dist/functions/helpers/streamify-response.d.ts +0 -3
- package/dist/functions/helpers/streamify-response.js +2 -14
- package/dist/functions/helpers/write-lambda-error.d.ts +3 -6
- package/dist/functions/helpers/write-lambda-error.js +1 -21
- package/dist/functions/index.d.ts +5 -0
- package/dist/functions/index.js +70 -38
- package/dist/functions/launch.js +103 -133
- package/dist/functions/renderer.d.ts +2 -2
- package/dist/functions/renderer.js +70 -123
- package/dist/functions/start.d.ts +1 -0
- package/dist/functions/start.js +3 -2
- package/dist/functions/still.d.ts +7 -2
- package/dist/functions/still.js +17 -34
- package/dist/functions/streaming/streaming.d.ts +15 -2
- package/dist/functions/streaming/streaming.js +8 -6
- package/dist/internals.d.ts +2 -1
- package/dist/shared/aws-clients.js +8 -0
- package/dist/shared/call-lambda.d.ts +5 -4
- package/dist/shared/call-lambda.js +53 -44
- package/dist/shared/constants.d.ts +14 -35
- package/dist/shared/constants.js +3 -31
- package/dist/shared/content-disposition-header.d.ts +0 -3
- package/dist/shared/get-function-version.js +0 -2
- package/dist/shared/is-flaky-error.js +4 -0
- package/dist/shared/parse-lambda-timings-key.d.ts +0 -2
- package/dist/shared/parse-lambda-timings-key.js +0 -14
- package/dist/shared/return-values.d.ts +0 -5
- package/package.json +18 -18
- package/remotionlambda-arm64.zip +0 -0
package/dist/functions/index.js
CHANGED
|
@@ -10,14 +10,15 @@ const leak_detection_1 = require("./helpers/leak-detection");
|
|
|
10
10
|
const lifecycle_1 = require("./helpers/lifecycle");
|
|
11
11
|
const print_cloudwatch_helper_1 = require("./helpers/print-cloudwatch-helper");
|
|
12
12
|
const streamify_response_1 = require("./helpers/streamify-response");
|
|
13
|
-
const streaming_payloads_1 = require("./helpers/streaming-payloads");
|
|
14
13
|
const info_1 = require("./info");
|
|
15
14
|
const launch_1 = require("./launch");
|
|
16
15
|
const progress_1 = require("./progress");
|
|
17
16
|
const renderer_2 = require("./renderer");
|
|
18
17
|
const start_1 = require("./start");
|
|
19
18
|
const still_1 = require("./still");
|
|
20
|
-
const
|
|
19
|
+
const stream_writer_1 = require("./streaming/stream-writer");
|
|
20
|
+
const streaming_1 = require("./streaming/streaming");
|
|
21
|
+
const innerHandler = async ({ params, responseWriter, context, }) => {
|
|
21
22
|
(0, leak_detection_1.setCurrentRequestId)(context.awsRequestId);
|
|
22
23
|
process.env.__RESERVED_IS_INSIDE_REMOTION_LAMBDA = 'true';
|
|
23
24
|
const timeoutInMilliseconds = context.getRemainingTimeInMillis();
|
|
@@ -38,19 +39,36 @@ const innerHandler = async (params, responseStream, context) => {
|
|
|
38
39
|
inputProps: JSON.stringify(params.inputProps),
|
|
39
40
|
isWarm,
|
|
40
41
|
}, params.logLevel);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
42
|
+
await new Promise((resolve, reject) => {
|
|
43
|
+
const onStream = (payload) => {
|
|
44
|
+
const message = (0, streaming_1.makeStreamPayload)({
|
|
45
|
+
message: payload,
|
|
46
|
+
});
|
|
47
|
+
responseWriter.write(message).catch((err) => {
|
|
48
|
+
reject(err);
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
if (params.streamed) {
|
|
52
|
+
onStream({
|
|
53
|
+
type: 'render-id-determined',
|
|
54
|
+
payload: { renderId },
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
(0, still_1.stillHandler)({
|
|
58
|
+
expectedBucketOwner: currentUserId,
|
|
59
|
+
params,
|
|
60
|
+
renderId,
|
|
61
|
+
onStream,
|
|
62
|
+
timeoutInMilliseconds,
|
|
63
|
+
})
|
|
64
|
+
.then((r) => {
|
|
65
|
+
resolve(r);
|
|
66
|
+
})
|
|
67
|
+
.catch((err) => {
|
|
68
|
+
reject(err);
|
|
69
|
+
});
|
|
53
70
|
});
|
|
71
|
+
await responseWriter.end();
|
|
54
72
|
return;
|
|
55
73
|
}
|
|
56
74
|
if (params.type === constants_1.LambdaRoutines.start) {
|
|
@@ -60,10 +78,10 @@ const innerHandler = async (params, responseStream, context) => {
|
|
|
60
78
|
}, params.logLevel);
|
|
61
79
|
const response = await (0, start_1.startHandler)(params, {
|
|
62
80
|
expectedBucketOwner: currentUserId,
|
|
81
|
+
timeoutInMilliseconds,
|
|
63
82
|
});
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
});
|
|
83
|
+
await responseWriter.write(Buffer.from(JSON.stringify(response)));
|
|
84
|
+
await responseWriter.end();
|
|
67
85
|
return;
|
|
68
86
|
}
|
|
69
87
|
if (params.type === constants_1.LambdaRoutines.launch) {
|
|
@@ -76,9 +94,8 @@ const innerHandler = async (params, responseStream, context) => {
|
|
|
76
94
|
expectedBucketOwner: currentUserId,
|
|
77
95
|
getRemainingTimeInMillis: context.getRemainingTimeInMillis,
|
|
78
96
|
});
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
97
|
+
await responseWriter.write(Buffer.from(JSON.stringify(response)));
|
|
98
|
+
await responseWriter.end();
|
|
82
99
|
return;
|
|
83
100
|
}
|
|
84
101
|
if (params.type === constants_1.LambdaRoutines.status) {
|
|
@@ -91,9 +108,8 @@ const innerHandler = async (params, responseStream, context) => {
|
|
|
91
108
|
timeoutInMilliseconds,
|
|
92
109
|
retriesRemaining: 2,
|
|
93
110
|
});
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
});
|
|
111
|
+
await responseWriter.write(Buffer.from(JSON.stringify(response)));
|
|
112
|
+
await responseWriter.end();
|
|
97
113
|
return;
|
|
98
114
|
}
|
|
99
115
|
if (params.type === constants_1.LambdaRoutines.renderer) {
|
|
@@ -104,13 +120,26 @@ const innerHandler = async (params, responseStream, context) => {
|
|
|
104
120
|
resolvedProps: JSON.stringify(params.resolvedProps),
|
|
105
121
|
isWarm,
|
|
106
122
|
}, params.logLevel);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
123
|
+
await new Promise((resolve, reject) => {
|
|
124
|
+
(0, renderer_2.rendererHandler)(params, {
|
|
125
|
+
expectedBucketOwner: currentUserId,
|
|
126
|
+
isWarm,
|
|
127
|
+
}, (payload) => {
|
|
128
|
+
const message = (0, streaming_1.makeStreamPayload)({
|
|
129
|
+
message: payload,
|
|
130
|
+
});
|
|
131
|
+
responseWriter.write(message).catch((err) => {
|
|
132
|
+
reject(err);
|
|
133
|
+
});
|
|
134
|
+
}, context)
|
|
135
|
+
.then((res) => {
|
|
136
|
+
resolve(res);
|
|
137
|
+
})
|
|
138
|
+
.catch((err) => {
|
|
139
|
+
reject(err);
|
|
140
|
+
});
|
|
113
141
|
});
|
|
142
|
+
await responseWriter.end();
|
|
114
143
|
return;
|
|
115
144
|
}
|
|
116
145
|
if (params.type === constants_1.LambdaRoutines.info) {
|
|
@@ -118,9 +147,8 @@ const innerHandler = async (params, responseStream, context) => {
|
|
|
118
147
|
isWarm,
|
|
119
148
|
}, params.logLevel);
|
|
120
149
|
const response = await (0, info_1.infoHandler)(params);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
});
|
|
150
|
+
await responseWriter.write(Buffer.from(JSON.stringify(response)));
|
|
151
|
+
await responseWriter.end();
|
|
124
152
|
return;
|
|
125
153
|
}
|
|
126
154
|
if (params.type === constants_1.LambdaRoutines.compositions) {
|
|
@@ -130,16 +158,20 @@ const innerHandler = async (params, responseStream, context) => {
|
|
|
130
158
|
const response = await (0, compositions_1.compositionsHandler)(params, {
|
|
131
159
|
expectedBucketOwner: currentUserId,
|
|
132
160
|
});
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
});
|
|
161
|
+
await responseWriter.write(Buffer.from(JSON.stringify(response)));
|
|
162
|
+
await responseWriter.end();
|
|
136
163
|
return;
|
|
137
164
|
}
|
|
138
165
|
throw new Error(constants_1.COMMAND_NOT_FOUND);
|
|
139
166
|
};
|
|
140
167
|
const routine = async (params, responseStream, context) => {
|
|
168
|
+
const responseWriter = (0, stream_writer_1.streamWriter)(responseStream);
|
|
141
169
|
try {
|
|
142
|
-
await innerHandler(
|
|
170
|
+
await innerHandler({
|
|
171
|
+
params,
|
|
172
|
+
responseWriter,
|
|
173
|
+
context,
|
|
174
|
+
});
|
|
143
175
|
}
|
|
144
176
|
catch (err) {
|
|
145
177
|
const res = {
|
|
@@ -147,8 +179,8 @@ const routine = async (params, responseStream, context) => {
|
|
|
147
179
|
message: err.message,
|
|
148
180
|
stack: err.stack,
|
|
149
181
|
};
|
|
150
|
-
|
|
151
|
-
|
|
182
|
+
await responseWriter.write(Buffer.from(JSON.stringify(res)));
|
|
183
|
+
await responseWriter.end();
|
|
152
184
|
}
|
|
153
185
|
};
|
|
154
186
|
exports.handler = (0, streamify_response_1.streamifyResponse)(routine);
|
package/dist/functions/launch.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.launchHandler = void 0;
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
5
|
-
const client_lambda_1 = require("@aws-sdk/client-lambda");
|
|
6
4
|
const renderer_1 = require("@remotion/renderer");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = require("path");
|
|
7
7
|
const version_1 = require("remotion/version");
|
|
8
|
-
const aws_clients_1 = require("../shared/aws-clients");
|
|
9
8
|
const compress_props_1 = require("../shared/compress-props");
|
|
10
9
|
const constants_1 = require("../shared/constants");
|
|
11
10
|
const docs_url_1 = require("../shared/docs-url");
|
|
@@ -20,40 +19,12 @@ const expected_out_name_1 = require("./helpers/expected-out-name");
|
|
|
20
19
|
const find_output_file_in_bucket_1 = require("./helpers/find-output-file-in-bucket");
|
|
21
20
|
const get_browser_instance_1 = require("./helpers/get-browser-instance");
|
|
22
21
|
const get_current_region_1 = require("./helpers/get-current-region");
|
|
23
|
-
const io_1 = require("./helpers/io");
|
|
24
22
|
const merge_chunks_1 = require("./helpers/merge-chunks");
|
|
25
|
-
const
|
|
23
|
+
const overall_render_progress_1 = require("./helpers/overall-render-progress");
|
|
24
|
+
const stream_renderer_1 = require("./helpers/stream-renderer");
|
|
26
25
|
const validate_composition_1 = require("./helpers/validate-composition");
|
|
27
26
|
const write_lambda_error_1 = require("./helpers/write-lambda-error");
|
|
28
|
-
const
|
|
29
|
-
try {
|
|
30
|
-
const result = await (0, aws_clients_1.getLambdaClient)((0, get_current_region_1.getCurrentRegionInFunction)()).send(new client_lambda_1.InvokeCommand({
|
|
31
|
-
FunctionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
|
|
32
|
-
Payload: JSON.stringify(payload),
|
|
33
|
-
InvocationType: 'Event',
|
|
34
|
-
}));
|
|
35
|
-
if (result.FunctionError) {
|
|
36
|
-
throw new Error(`Lambda function ${functionName} returned an error: ${result.FunctionError} ${result.LogResult}`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
catch (err) {
|
|
40
|
-
if (err.name === 'ResourceConflictException') {
|
|
41
|
-
if (retries > 10) {
|
|
42
|
-
throw err;
|
|
43
|
-
}
|
|
44
|
-
await new Promise((resolve) => {
|
|
45
|
-
setTimeout(resolve, 1000);
|
|
46
|
-
});
|
|
47
|
-
return callFunctionWithRetry({
|
|
48
|
-
payload,
|
|
49
|
-
retries: retries + 1,
|
|
50
|
-
functionName,
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
throw err;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
const innerLaunchHandler = async ({ functionName, params, options, }) => {
|
|
27
|
+
const innerLaunchHandler = async ({ functionName, params, options, overallProgress, }) => {
|
|
57
28
|
var _a, _b, _c, _d, _e;
|
|
58
29
|
if (params.type !== constants_1.LambdaRoutines.launch) {
|
|
59
30
|
throw new Error('Expected launch type');
|
|
@@ -75,6 +46,7 @@ const innerLaunchHandler = async ({ functionName, params, options, }) => {
|
|
|
75
46
|
renderer_1.RenderInternals.Log.info(logOptions, 'Waiting for browser to be ready:', serializedInputPropsWithCustomSchema);
|
|
76
47
|
const { instance } = await browserInstance;
|
|
77
48
|
renderer_1.RenderInternals.Log.info(logOptions, 'Validating composition, input props:', serializedInputPropsWithCustomSchema);
|
|
49
|
+
const startTime = Date.now();
|
|
78
50
|
const comp = await (0, validate_composition_1.validateComposition)({
|
|
79
51
|
serveUrl: params.serveUrl,
|
|
80
52
|
composition: params.composition,
|
|
@@ -131,8 +103,8 @@ const innerLaunchHandler = async ({ functionName, params, options, }) => {
|
|
|
131
103
|
if (chunks.length > constants_1.MAX_FUNCTIONS_PER_RENDER) {
|
|
132
104
|
throw new Error(`Too many functions: This render would cause ${chunks.length} functions to spawn. We limit this amount to ${constants_1.MAX_FUNCTIONS_PER_RENDER} functions as more would result in diminishing returns. Values set: frameCount = ${frameCount}, framesPerLambda=${framesPerLambda}. See ${docs_url_1.DOCS_URL}/docs/lambda/concurrency#too-many-functions for help.`);
|
|
133
105
|
}
|
|
106
|
+
overallProgress.setExpectedChunks(chunks.length);
|
|
134
107
|
const sortedChunks = chunks.slice().sort((a, b) => a[0] - b[0]);
|
|
135
|
-
const reqSend = (0, timer_1.timer)('sending off requests', params.logLevel);
|
|
136
108
|
const serializedResolved = (0, compress_props_1.serializeOrThrow)(comp.props, 'resolved-props');
|
|
137
109
|
const needsToUpload = (0, compress_props_1.getNeedsToUpload)('video-or-audio', [
|
|
138
110
|
serializedResolved.length,
|
|
@@ -148,6 +120,9 @@ const innerLaunchHandler = async ({ functionName, params, options, }) => {
|
|
|
148
120
|
needsToUpload,
|
|
149
121
|
});
|
|
150
122
|
const fps = comp.fps / params.everyNthFrame;
|
|
123
|
+
// If for 150 functions, we stream every frame, we DDos ourselves.
|
|
124
|
+
// Throttling a bit, allowing more progress if there is lower concurrency.
|
|
125
|
+
const progressEveryNthFrame = Math.ceil(chunks.length / 15);
|
|
151
126
|
const lambdaPayloads = chunks.map((chunkPayload) => {
|
|
152
127
|
var _a;
|
|
153
128
|
const payload = {
|
|
@@ -195,6 +170,7 @@ const innerLaunchHandler = async ({ functionName, params, options, }) => {
|
|
|
195
170
|
preferLossless: params.preferLossless,
|
|
196
171
|
compositionStart: realFrameRange[0],
|
|
197
172
|
framesPerLambda,
|
|
173
|
+
progressEveryNthFrame,
|
|
198
174
|
};
|
|
199
175
|
return payload;
|
|
200
176
|
});
|
|
@@ -235,40 +211,36 @@ const innerLaunchHandler = async ({ functionName, params, options, }) => {
|
|
|
235
211
|
const { key, renderBucketName, customCredentials } = (0, expected_out_name_1.getExpectedOutName)(renderMetadata, params.bucketName, typeof params.outName === 'string' || typeof params.outName === 'undefined'
|
|
236
212
|
? null
|
|
237
213
|
: (_e = (_d = params.outName) === null || _d === void 0 ? void 0 : _d.s3OutputProvider) !== null && _e !== void 0 ? _e : null);
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
if (
|
|
246
|
-
|
|
247
|
-
await (0, io_1.lambdaDeleteFile)({
|
|
248
|
-
bucketName: renderBucketName,
|
|
249
|
-
customCredentials,
|
|
250
|
-
key,
|
|
251
|
-
region: (0, get_current_region_1.getCurrentRegionInFunction)(),
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
else {
|
|
255
|
-
throw new TypeError(`Output file "${key}" in bucket "${renderBucketName}" in region "${(0, get_current_region_1.getCurrentRegionInFunction)()}" already exists. Delete it before re-rendering, or use the overwrite option to delete it before render."`);
|
|
214
|
+
if (!params.overwrite) {
|
|
215
|
+
const output = await (0, find_output_file_in_bucket_1.findOutputFileInBucket)({
|
|
216
|
+
bucketName: params.bucketName,
|
|
217
|
+
customCredentials,
|
|
218
|
+
renderMetadata,
|
|
219
|
+
region: (0, get_current_region_1.getCurrentRegionInFunction)(),
|
|
220
|
+
});
|
|
221
|
+
if (output) {
|
|
222
|
+
throw new TypeError(`Output file "${key}" in bucket "${renderBucketName}" in region "${(0, get_current_region_1.getCurrentRegionInFunction)()}" already exists. Delete it before re-rendering, or set the 'overwrite' option in renderMediaOnLambda() to overwrite it."`);
|
|
256
223
|
}
|
|
257
224
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
});
|
|
225
|
+
overallProgress.setRenderMetadata(renderMetadata);
|
|
226
|
+
const outdir = (0, path_1.join)(renderer_1.RenderInternals.tmpDir(constants_1.CONCAT_FOLDER_TOKEN), 'bucket');
|
|
227
|
+
if ((0, fs_1.existsSync)(outdir)) {
|
|
228
|
+
(0, fs_1.rmSync)(outdir, {
|
|
229
|
+
recursive: true,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
(0, fs_1.mkdirSync)(outdir);
|
|
233
|
+
const files = [];
|
|
268
234
|
await Promise.all(lambdaPayloads.map(async (payload) => {
|
|
269
|
-
await
|
|
235
|
+
await (0, stream_renderer_1.streamRendererFunctionWithRetry)({
|
|
236
|
+
files,
|
|
237
|
+
functionName,
|
|
238
|
+
outdir,
|
|
239
|
+
overallProgress,
|
|
240
|
+
payload,
|
|
241
|
+
logLevel: params.logLevel,
|
|
242
|
+
});
|
|
270
243
|
}));
|
|
271
|
-
reqSend.end();
|
|
272
244
|
const postRenderData = await (0, merge_chunks_1.mergeChunksAndFinishRender)({
|
|
273
245
|
bucketName: params.bucketName,
|
|
274
246
|
renderId: params.renderId,
|
|
@@ -293,6 +265,10 @@ const innerLaunchHandler = async ({ functionName, params, options, }) => {
|
|
|
293
265
|
binariesDirectory: null,
|
|
294
266
|
preferLossless: params.preferLossless,
|
|
295
267
|
compositionStart: realFrameRange[0],
|
|
268
|
+
outdir,
|
|
269
|
+
files: files.sort(),
|
|
270
|
+
overallProgress,
|
|
271
|
+
startTime,
|
|
296
272
|
});
|
|
297
273
|
return postRenderData;
|
|
298
274
|
};
|
|
@@ -308,6 +284,7 @@ const launchHandler = async (params, options) => {
|
|
|
308
284
|
};
|
|
309
285
|
const onTimeout = async () => {
|
|
310
286
|
var _a;
|
|
287
|
+
renderer_1.RenderInternals.Log.error({ indent: false, logLevel: params.logLevel }, 'Function is about to time out. Can not finish render.');
|
|
311
288
|
if (!params.webhook) {
|
|
312
289
|
return;
|
|
313
290
|
}
|
|
@@ -335,34 +312,39 @@ const launchHandler = async (params, options) => {
|
|
|
335
312
|
}
|
|
336
313
|
renderer_1.RenderInternals.Log.error({ indent: false, logLevel: params.logLevel }, 'Failed to invoke webhook:');
|
|
337
314
|
renderer_1.RenderInternals.Log.error({ indent: false, logLevel: params.logLevel }, err);
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
willRetry: false,
|
|
351
|
-
totalAttempts: 1,
|
|
352
|
-
},
|
|
353
|
-
renderId: params.renderId,
|
|
354
|
-
expectedBucketOwner: options.expectedBucketOwner,
|
|
315
|
+
overallProgress.addErrorWithoutUpload({
|
|
316
|
+
type: 'webhook',
|
|
317
|
+
message: err.message,
|
|
318
|
+
name: err.name,
|
|
319
|
+
stack: err.stack,
|
|
320
|
+
tmpDir: null,
|
|
321
|
+
frame: 0,
|
|
322
|
+
chunk: 0,
|
|
323
|
+
isFatal: false,
|
|
324
|
+
attempt: 1,
|
|
325
|
+
willRetry: false,
|
|
326
|
+
totalAttempts: 1,
|
|
355
327
|
});
|
|
328
|
+
overallProgress.upload();
|
|
356
329
|
}
|
|
357
330
|
};
|
|
358
331
|
let webhookInvoked = false;
|
|
359
332
|
const webhookDueToTimeout = setTimeout(onTimeout, Math.max(options.getRemainingTimeInMillis() - 1000, 1000));
|
|
360
333
|
renderer_1.RenderInternals.Log.info(logOptions, `Function has ${Math.max(options.getRemainingTimeInMillis() - 1000, 1000)} before it times out`);
|
|
334
|
+
const overallProgress = (0, overall_render_progress_1.makeOverallRenderProgress)({
|
|
335
|
+
renderId: params.renderId,
|
|
336
|
+
bucketName: params.bucketName,
|
|
337
|
+
expectedBucketOwner: options.expectedBucketOwner,
|
|
338
|
+
region: (0, get_current_region_1.getCurrentRegionInFunction)(),
|
|
339
|
+
timeoutTimestamp: options.getRemainingTimeInMillis() + Date.now(),
|
|
340
|
+
logLevel: params.logLevel,
|
|
341
|
+
});
|
|
361
342
|
try {
|
|
362
343
|
const postRenderData = await innerLaunchHandler({
|
|
363
344
|
functionName,
|
|
364
345
|
params,
|
|
365
346
|
options,
|
|
347
|
+
overallProgress,
|
|
366
348
|
});
|
|
367
349
|
clearTimeout(webhookDueToTimeout);
|
|
368
350
|
if (!params.webhook || webhookInvoked) {
|
|
@@ -394,24 +376,20 @@ const launchHandler = async (params, options) => {
|
|
|
394
376
|
if (process.env.NODE_ENV === 'test') {
|
|
395
377
|
throw err;
|
|
396
378
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
willRetry: false,
|
|
410
|
-
totalAttempts: 1,
|
|
411
|
-
},
|
|
412
|
-
renderId: params.renderId,
|
|
413
|
-
expectedBucketOwner: options.expectedBucketOwner,
|
|
379
|
+
overallProgress.addErrorWithoutUpload({
|
|
380
|
+
type: 'webhook',
|
|
381
|
+
message: err.message,
|
|
382
|
+
name: err.name,
|
|
383
|
+
stack: err.stack,
|
|
384
|
+
tmpDir: null,
|
|
385
|
+
frame: 0,
|
|
386
|
+
chunk: 0,
|
|
387
|
+
isFatal: false,
|
|
388
|
+
attempt: 1,
|
|
389
|
+
willRetry: false,
|
|
390
|
+
totalAttempts: 1,
|
|
414
391
|
});
|
|
392
|
+
overallProgress.upload();
|
|
415
393
|
renderer_1.RenderInternals.Log.error({ indent: false, logLevel: params.logLevel }, 'Failed to invoke webhook:');
|
|
416
394
|
renderer_1.RenderInternals.Log.error({ indent: false, logLevel: params.logLevel }, err);
|
|
417
395
|
}
|
|
@@ -424,24 +402,20 @@ const launchHandler = async (params, options) => {
|
|
|
424
402
|
throw err;
|
|
425
403
|
}
|
|
426
404
|
renderer_1.RenderInternals.Log.error({ indent: false, logLevel: params.logLevel }, 'Error occurred', err);
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
willRetry: false,
|
|
440
|
-
message: err.message,
|
|
441
|
-
},
|
|
442
|
-
expectedBucketOwner: options.expectedBucketOwner,
|
|
443
|
-
renderId: params.renderId,
|
|
405
|
+
overallProgress.addErrorWithoutUpload({
|
|
406
|
+
chunk: null,
|
|
407
|
+
frame: null,
|
|
408
|
+
name: err.name,
|
|
409
|
+
stack: err.stack,
|
|
410
|
+
type: 'stitcher',
|
|
411
|
+
isFatal: true,
|
|
412
|
+
tmpDir: (0, write_lambda_error_1.getTmpDirStateIfENoSp)(err.stack),
|
|
413
|
+
attempt: 1,
|
|
414
|
+
totalAttempts: 1,
|
|
415
|
+
willRetry: false,
|
|
416
|
+
message: err.message,
|
|
444
417
|
});
|
|
418
|
+
await overallProgress.upload();
|
|
445
419
|
renderer_1.RenderInternals.Log.error({ indent: false, logLevel: params.logLevel }, 'Wrote error to S3');
|
|
446
420
|
clearTimeout(webhookDueToTimeout);
|
|
447
421
|
if (params.webhook && !webhookInvoked) {
|
|
@@ -469,24 +443,20 @@ const launchHandler = async (params, options) => {
|
|
|
469
443
|
if (process.env.NODE_ENV === 'test') {
|
|
470
444
|
throw error;
|
|
471
445
|
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
willRetry: false,
|
|
485
|
-
totalAttempts: 1,
|
|
486
|
-
},
|
|
487
|
-
renderId: params.renderId,
|
|
488
|
-
expectedBucketOwner: options.expectedBucketOwner,
|
|
446
|
+
overallProgress.addErrorWithoutUpload({
|
|
447
|
+
type: 'webhook',
|
|
448
|
+
message: err.message,
|
|
449
|
+
name: err.name,
|
|
450
|
+
stack: err.stack,
|
|
451
|
+
tmpDir: null,
|
|
452
|
+
frame: 0,
|
|
453
|
+
chunk: 0,
|
|
454
|
+
isFatal: false,
|
|
455
|
+
attempt: 1,
|
|
456
|
+
willRetry: false,
|
|
457
|
+
totalAttempts: 1,
|
|
489
458
|
});
|
|
459
|
+
overallProgress.upload();
|
|
490
460
|
renderer_1.RenderInternals.Log.error({ indent: false, logLevel: params.logLevel }, 'Failed to invoke webhook:');
|
|
491
461
|
renderer_1.RenderInternals.Log.error({ indent: false, logLevel: params.logLevel }, error);
|
|
492
462
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { LambdaPayload } from '../shared/constants';
|
|
2
2
|
import type { RequestContext } from './helpers/request-context';
|
|
3
|
+
import type { OnStream } from './streaming/streaming';
|
|
3
4
|
type Options = {
|
|
4
5
|
expectedBucketOwner: string;
|
|
5
6
|
isWarm: boolean;
|
|
6
7
|
};
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const rendererHandler: (params: LambdaPayload, options: Options, requestContext: RequestContext) => Promise<{
|
|
8
|
+
export declare const rendererHandler: (params: LambdaPayload, options: Options, onStream: OnStream, requestContext: RequestContext) => Promise<{
|
|
9
9
|
type: 'success';
|
|
10
10
|
}>;
|
|
11
11
|
export {};
|