@remotion/serverless 4.0.245 → 4.0.246
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/.turbo/turbo-make.log +1 -1
- package/dist/best-frames-per-function-param.js +5 -5
- package/dist/client.d.ts +9 -0
- package/dist/client.js +30 -12
- package/dist/compress-props.d.ts +6 -2
- package/dist/compress-props.js +5 -3
- package/dist/concat-videos.d.ts +3 -4
- package/dist/concat-videos.js +2 -2
- package/dist/constants.d.ts +39 -3
- package/dist/constants.js +8 -1
- package/dist/create-post-render-data.d.ts +1 -1
- package/dist/create-post-render-data.js +2 -2
- package/dist/estimate-price-from-bucket.d.ts +2 -2
- package/dist/estimate-price-from-bucket.js +4 -4
- package/dist/expected-out-name.d.ts +1 -1
- package/dist/get-browser-instance.d.ts +5 -12
- package/dist/get-browser-instance.js +8 -7
- package/dist/get-custom-out-name.d.ts +1 -1
- package/dist/get-or-create-bucket.d.ts +1 -1
- package/dist/handlers/check-version-mismatch.d.ts +8 -0
- package/dist/handlers/check-version-mismatch.js +23 -0
- package/dist/handlers/compositions.d.ts +7 -2
- package/dist/handlers/compositions.js +25 -25
- package/dist/handlers/launch.d.ts +3 -2
- package/dist/handlers/launch.js +30 -31
- package/dist/handlers/progress.d.ts +6 -2
- package/dist/handlers/progress.js +23 -20
- package/dist/handlers/renderer.d.ts +3 -2
- package/dist/handlers/renderer.js +13 -11
- package/dist/handlers/start.d.ts +7 -2
- package/dist/handlers/start.js +10 -11
- package/dist/handlers/still.d.ts +2 -1
- package/dist/handlers/still.js +68 -67
- package/dist/index.d.ts +21 -5
- package/dist/index.js +54 -7
- package/dist/info.d.ts +1 -1
- package/dist/inner-routine.d.ts +22 -0
- package/dist/inner-routine.js +267 -0
- package/dist/inspect-error.d.ts +2 -2
- package/dist/invoke-webhook.d.ts +14 -11
- package/dist/invoke-webhook.js +1 -1
- package/dist/is-warm.d.ts +2 -0
- package/dist/is-warm.js +10 -0
- package/dist/make-bucket-name.d.ts +1 -1
- package/dist/make-timeout-error.d.ts +1 -1
- package/dist/make-timeout-message.js +3 -2
- package/dist/merge-chunks.d.ts +2 -1
- package/dist/merge-chunks.js +3 -3
- package/dist/most-expensive-chunks.d.ts +2 -2
- package/dist/most-expensive-chunks.js +1 -1
- package/dist/overall-render-progress.d.ts +3 -3
- package/dist/plan-frame-ranges.d.ts +2 -2
- package/dist/plan-frame-ranges.js +4 -4
- package/dist/print-logging-grep-helper.d.ts +4 -0
- package/dist/print-logging-grep-helper.js +12 -0
- package/dist/progress.js +2 -2
- package/dist/provider-implementation.d.ts +152 -3
- package/dist/render-metadata.d.ts +1 -1
- package/dist/render-progress.d.ts +1 -1
- package/dist/streaming/streaming.d.ts +6 -6
- package/dist/streaming/streaming.js +3 -3
- package/dist/types.d.ts +3 -2
- package/dist/validate-composition.d.ts +1 -1
- package/dist/validate-composition.js +11 -1
- package/dist/validate-frames-per-function.d.ts +2 -2
- package/dist/validate-frames-per-function.js +13 -13
- package/dist/{write-lambda-error.d.ts → write-error-to-storage.d.ts} +4 -4
- package/package.json +6 -5
- package/tsconfig.tsbuildinfo +1 -1
- package/.turbo/turbo-formatting.log +0 -7
- package/.turbo/turbo-lint.log +0 -11
- package/dist/compositions.d.ts +0 -11
- package/dist/compositions.js +0 -82
- package/dist/still.d.ts +0 -28
- package/dist/still.js +0 -2
- package/dist/validate-frames-per-lambda.d.ts +0 -4
- package/dist/validate-frames-per-lambda.js +0 -29
- /package/dist/{write-lambda-error.js → write-error-to-storage.js} +0 -0
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import type { ServerlessPayload } from '../constants';
|
|
2
2
|
import type { WebhookClient } from '../invoke-webhook';
|
|
3
|
-
import type { ProviderSpecifics } from '../provider-implementation';
|
|
3
|
+
import type { InsideFunctionSpecifics, ProviderSpecifics } from '../provider-implementation';
|
|
4
4
|
import type { CloudProvider } from '../types';
|
|
5
5
|
type Options = {
|
|
6
6
|
expectedBucketOwner: string;
|
|
7
7
|
getRemainingTimeInMillis: () => number;
|
|
8
8
|
};
|
|
9
|
-
export declare const launchHandler: <Provider extends CloudProvider>({ params, options, providerSpecifics, client, }: {
|
|
9
|
+
export declare const launchHandler: <Provider extends CloudProvider>({ params, options, providerSpecifics, client, insideFunctionSpecifics, }: {
|
|
10
10
|
params: ServerlessPayload<Provider>;
|
|
11
11
|
options: Options;
|
|
12
12
|
providerSpecifics: ProviderSpecifics<Provider>;
|
|
13
|
+
insideFunctionSpecifics: InsideFunctionSpecifics;
|
|
13
14
|
client: WebhookClient;
|
|
14
15
|
}) => Promise<{
|
|
15
16
|
type: "success";
|
package/dist/handlers/launch.js
CHANGED
|
@@ -17,23 +17,23 @@ const find_output_file_in_bucket_1 = require("../find-output-file-in-bucket");
|
|
|
17
17
|
const merge_chunks_1 = require("../merge-chunks");
|
|
18
18
|
const plan_frame_ranges_1 = require("../plan-frame-ranges");
|
|
19
19
|
const stream_renderer_1 = require("../stream-renderer");
|
|
20
|
-
const validate_1 = require("../validate");
|
|
21
20
|
const validate_composition_1 = require("../validate-composition");
|
|
22
21
|
const validate_frames_per_function_1 = require("../validate-frames-per-function");
|
|
23
22
|
const validate_outname_1 = require("../validate-outname");
|
|
24
23
|
const validate_privacy_1 = require("../validate-privacy");
|
|
25
|
-
const
|
|
26
|
-
const innerLaunchHandler = async ({ functionName, params, options, overallProgress, registerCleanupTask, providerSpecifics, }) => {
|
|
24
|
+
const write_error_to_storage_1 = require("../write-error-to-storage");
|
|
25
|
+
const innerLaunchHandler = async ({ functionName, params, options, overallProgress, registerCleanupTask, providerSpecifics, insideFunctionSpecifics, }) => {
|
|
27
26
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
28
27
|
if (params.type !== constants_1.ServerlessRoutines.launch) {
|
|
29
28
|
throw new Error('Expected launch type');
|
|
30
29
|
}
|
|
31
30
|
const startedDate = Date.now();
|
|
32
|
-
const browserInstance =
|
|
31
|
+
const browserInstance = insideFunctionSpecifics.getBrowserInstance({
|
|
33
32
|
logLevel: params.logLevel,
|
|
34
33
|
indent: false,
|
|
35
34
|
chromiumOptions: params.chromiumOptions,
|
|
36
35
|
providerSpecifics,
|
|
36
|
+
insideFunctionSpecifics,
|
|
37
37
|
});
|
|
38
38
|
const inputPropsPromise = (0, compress_props_1.decompressInputProps)({
|
|
39
39
|
bucketName: params.bucketName,
|
|
@@ -68,7 +68,7 @@ const innerLaunchHandler = async ({ functionName, params, options, overallProgre
|
|
|
68
68
|
server: undefined,
|
|
69
69
|
offthreadVideoCacheSizeInBytes: params.offthreadVideoCacheSizeInBytes,
|
|
70
70
|
onBrowserDownload: () => {
|
|
71
|
-
throw new Error('Should not download a browser in
|
|
71
|
+
throw new Error('Should not download a browser in a function');
|
|
72
72
|
},
|
|
73
73
|
onServeUrlVisited: () => {
|
|
74
74
|
overallProgress.setServeUrlOpened(Date.now());
|
|
@@ -77,25 +77,18 @@ const innerLaunchHandler = async ({ functionName, params, options, overallProgre
|
|
|
77
77
|
});
|
|
78
78
|
overallProgress.setCompositionValidated(Date.now());
|
|
79
79
|
renderer_1.RenderInternals.Log.info(logOptions, 'Composition validated, resolved props', comp.props);
|
|
80
|
-
(0, validate_1.validateDurationInFrames)(comp.durationInFrames, {
|
|
81
|
-
component: 'passed to a Lambda render',
|
|
82
|
-
allowFloats: false,
|
|
83
|
-
});
|
|
84
|
-
(0, validate_1.validateFps)(comp.fps, 'passed to a Lambda render', false);
|
|
85
|
-
(0, validate_1.validateDimension)(comp.height, 'height', 'passed to a Lambda render');
|
|
86
|
-
(0, validate_1.validateDimension)(comp.width, 'width', 'passed to a Lambda render');
|
|
87
80
|
renderer_1.RenderInternals.validateBitrate(params.audioBitrate, 'audioBitrate');
|
|
88
81
|
renderer_1.RenderInternals.validateBitrate(params.videoBitrate, 'videoBitrate');
|
|
89
82
|
renderer_1.RenderInternals.validateConcurrency({
|
|
90
|
-
value: params.
|
|
83
|
+
value: params.concurrencyPerFunction,
|
|
91
84
|
setting: 'concurrencyPerLambda',
|
|
92
85
|
checkIfValidForCurrentMachine: ((_b = params.rendererFunctionName) !== null && _b !== void 0 ? _b : null) === null,
|
|
93
86
|
});
|
|
94
87
|
const realFrameRange = renderer_1.RenderInternals.getRealFrameRange(comp.durationInFrames, params.frameRange);
|
|
95
88
|
const frameCount = renderer_1.RenderInternals.getFramesToRender(realFrameRange, params.everyNthFrame);
|
|
96
|
-
const framesPerLambda = (_c = params.
|
|
89
|
+
const framesPerLambda = (_c = params.framesPerFunction) !== null && _c !== void 0 ? _c : (0, best_frames_per_function_param_1.bestFramesPerFunctionParam)(frameCount.length);
|
|
97
90
|
(0, validate_frames_per_function_1.validateFramesPerFunction)({
|
|
98
|
-
framesPerLambda,
|
|
91
|
+
framesPerFunction: framesPerLambda,
|
|
99
92
|
durationInFrames: frameCount.length,
|
|
100
93
|
});
|
|
101
94
|
(0, validate_outname_1.validateOutname)({
|
|
@@ -107,7 +100,7 @@ const innerLaunchHandler = async ({ functionName, params, options, overallProgre
|
|
|
107
100
|
(0, validate_privacy_1.validatePrivacy)(params.privacy, true);
|
|
108
101
|
renderer_1.RenderInternals.validatePuppeteerTimeout(params.timeoutInMilliseconds);
|
|
109
102
|
const { chunks } = (0, plan_frame_ranges_1.planFrameRanges)({
|
|
110
|
-
framesPerLambda,
|
|
103
|
+
framesPerFunction: framesPerLambda,
|
|
111
104
|
frameRange: realFrameRange,
|
|
112
105
|
everyNthFrame: params.everyNthFrame,
|
|
113
106
|
});
|
|
@@ -117,13 +110,17 @@ const innerLaunchHandler = async ({ functionName, params, options, overallProgre
|
|
|
117
110
|
overallProgress.setExpectedChunks(chunks.length);
|
|
118
111
|
const sortedChunks = chunks.slice().sort((a, b) => a[0] - b[0]);
|
|
119
112
|
const serializedResolved = (0, compress_props_1.serializeOrThrow)(comp.props, 'resolved-props');
|
|
120
|
-
const needsToUpload = (0, compress_props_1.getNeedsToUpload)(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
113
|
+
const needsToUpload = (0, compress_props_1.getNeedsToUpload)({
|
|
114
|
+
type: 'video-or-audio',
|
|
115
|
+
sizes: [
|
|
116
|
+
serializedResolved.length,
|
|
117
|
+
params.inputProps.type === 'bucket-url'
|
|
118
|
+
? params.inputProps.hash.length
|
|
119
|
+
: params.inputProps.payload.length,
|
|
120
|
+
JSON.stringify(params.envVariables).length,
|
|
121
|
+
],
|
|
122
|
+
providerSpecifics,
|
|
123
|
+
});
|
|
127
124
|
const serializedResolvedProps = await (0, compress_props_1.compressInputProps)({
|
|
128
125
|
propsType: 'resolved-props',
|
|
129
126
|
region: providerSpecifics.getCurrentRegionInFunction(),
|
|
@@ -177,7 +174,7 @@ const innerLaunchHandler = async ({ functionName, params, options, overallProgre
|
|
|
177
174
|
chromiumOptions: params.chromiumOptions,
|
|
178
175
|
scale: params.scale,
|
|
179
176
|
everyNthFrame: params.everyNthFrame,
|
|
180
|
-
concurrencyPerLambda: params.
|
|
177
|
+
concurrencyPerLambda: params.concurrencyPerFunction,
|
|
181
178
|
muted: params.muted,
|
|
182
179
|
audioBitrate: params.audioBitrate,
|
|
183
180
|
videoBitrate: params.videoBitrate,
|
|
@@ -218,7 +215,7 @@ const innerLaunchHandler = async ({ functionName, params, options, overallProgre
|
|
|
218
215
|
inputProps: params.inputProps,
|
|
219
216
|
lambdaVersion: version_1.VERSION,
|
|
220
217
|
framesPerLambda,
|
|
221
|
-
memorySizeInMb:
|
|
218
|
+
memorySizeInMb: insideFunctionSpecifics.getCurrentMemorySizeInMb(),
|
|
222
219
|
region: providerSpecifics.getCurrentRegionInFunction(),
|
|
223
220
|
renderId: params.renderId,
|
|
224
221
|
outName: (_d = params.outName) !== null && _d !== void 0 ? _d : undefined,
|
|
@@ -232,7 +229,7 @@ const innerLaunchHandler = async ({ functionName, params, options, overallProgre
|
|
|
232
229
|
audioBitrate: params.audioBitrate,
|
|
233
230
|
muted: params.muted,
|
|
234
231
|
metadata: params.metadata,
|
|
235
|
-
functionName:
|
|
232
|
+
functionName: insideFunctionSpecifics.getCurrentFunctionName(),
|
|
236
233
|
dimensions: {
|
|
237
234
|
width: comp.width * ((_e = params.scale) !== null && _e !== void 0 ? _e : 1),
|
|
238
235
|
height: comp.height * ((_f = params.scale) !== null && _f !== void 0 ? _f : 1),
|
|
@@ -242,7 +239,7 @@ const innerLaunchHandler = async ({ functionName, params, options, overallProgre
|
|
|
242
239
|
? null
|
|
243
240
|
: ((_h = (_g = params.outName) === null || _g === void 0 ? void 0 : _g.s3OutputProvider) !== null && _h !== void 0 ? _h : null));
|
|
244
241
|
if (!params.overwrite) {
|
|
245
|
-
const findOutputFile =
|
|
242
|
+
const findOutputFile = insideFunctionSpecifics.timer('Checking if output file already exists', params.logLevel);
|
|
246
243
|
const output = await (0, find_output_file_in_bucket_1.findOutputFileInBucket)({
|
|
247
244
|
bucketName: params.bucketName,
|
|
248
245
|
customCredentials,
|
|
@@ -358,15 +355,16 @@ const innerLaunchHandler = async ({ functionName, params, options, overallProgre
|
|
|
358
355
|
startTime,
|
|
359
356
|
providerSpecifics,
|
|
360
357
|
forcePathStyle: params.forcePathStyle,
|
|
358
|
+
insideFunctionSpecifics,
|
|
361
359
|
});
|
|
362
360
|
return postRenderData;
|
|
363
361
|
};
|
|
364
|
-
const launchHandler = async ({ params, options, providerSpecifics, client, }) => {
|
|
362
|
+
const launchHandler = async ({ params, options, providerSpecifics, client, insideFunctionSpecifics, }) => {
|
|
365
363
|
var _a, _b, _c;
|
|
366
364
|
if (params.type !== constants_1.ServerlessRoutines.launch) {
|
|
367
365
|
throw new Error('Expected launch type');
|
|
368
366
|
}
|
|
369
|
-
const functionName = (_a = params.rendererFunctionName) !== null && _a !== void 0 ? _a :
|
|
367
|
+
const functionName = (_a = params.rendererFunctionName) !== null && _a !== void 0 ? _a : insideFunctionSpecifics.getCurrentFunctionName();
|
|
370
368
|
const logOptions = {
|
|
371
369
|
indent: false,
|
|
372
370
|
logLevel: params.logLevel,
|
|
@@ -472,6 +470,7 @@ const launchHandler = async ({ params, options, providerSpecifics, client, }) =>
|
|
|
472
470
|
overallProgress,
|
|
473
471
|
registerCleanupTask,
|
|
474
472
|
providerSpecifics,
|
|
473
|
+
insideFunctionSpecifics,
|
|
475
474
|
});
|
|
476
475
|
clearTimeout(webhookDueToTimeout);
|
|
477
476
|
if (!params.webhook || webhookInvoked) {
|
|
@@ -538,7 +537,7 @@ const launchHandler = async ({ params, options, providerSpecifics, client, }) =>
|
|
|
538
537
|
stack: err.stack,
|
|
539
538
|
type: 'stitcher',
|
|
540
539
|
isFatal: true,
|
|
541
|
-
tmpDir: (0,
|
|
540
|
+
tmpDir: (0, write_error_to_storage_1.getTmpDirStateIfENoSp)(err.stack, providerSpecifics),
|
|
542
541
|
attempt: 1,
|
|
543
542
|
totalAttempts: 1,
|
|
544
543
|
willRetry: false,
|
|
@@ -595,7 +594,7 @@ const launchHandler = async ({ params, options, providerSpecifics, client, }) =>
|
|
|
595
594
|
throw err;
|
|
596
595
|
}
|
|
597
596
|
finally {
|
|
598
|
-
|
|
597
|
+
insideFunctionSpecifics.forgetBrowserEventLoop(params.logLevel);
|
|
599
598
|
}
|
|
600
599
|
};
|
|
601
600
|
exports.launchHandler = launchHandler;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ServerlessPayload } from '../constants';
|
|
2
|
-
import type { ProviderSpecifics } from '../provider-implementation';
|
|
2
|
+
import type { InsideFunctionSpecifics, ProviderSpecifics } from '../provider-implementation';
|
|
3
3
|
import type { GenericRenderProgress } from '../render-progress';
|
|
4
4
|
import type { CloudProvider } from '../types';
|
|
5
5
|
type Options<Provider extends CloudProvider> = {
|
|
@@ -7,6 +7,10 @@ type Options<Provider extends CloudProvider> = {
|
|
|
7
7
|
timeoutInMilliseconds: number;
|
|
8
8
|
retriesRemaining: number;
|
|
9
9
|
providerSpecifics: ProviderSpecifics<Provider>;
|
|
10
|
+
insideFunctionSpecifics: InsideFunctionSpecifics;
|
|
10
11
|
};
|
|
11
|
-
export declare const progressHandler: <Provider extends CloudProvider>(
|
|
12
|
+
export declare const progressHandler: <Provider extends CloudProvider>({ params, options, }: {
|
|
13
|
+
params: ServerlessPayload<Provider>;
|
|
14
|
+
options: Options<Provider>;
|
|
15
|
+
}) => Promise<GenericRenderProgress<Provider>>;
|
|
12
16
|
export {};
|
|
@@ -1,32 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.progressHandler = void 0;
|
|
4
|
-
const version_1 = require("remotion/version");
|
|
5
4
|
const constants_1 = require("../constants");
|
|
6
5
|
const progress_1 = require("../progress");
|
|
7
|
-
const
|
|
6
|
+
const check_version_mismatch_1 = require("./check-version-mismatch");
|
|
7
|
+
const progressHandler = async ({ params, options, }) => {
|
|
8
8
|
var _a;
|
|
9
|
-
if (
|
|
9
|
+
if (params.type !== constants_1.ServerlessRoutines.status) {
|
|
10
10
|
throw new TypeError('Expected status type');
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
12
|
+
(0, check_version_mismatch_1.checkVersionMismatch)({
|
|
13
|
+
apiName: 'getRenderProgress()',
|
|
14
|
+
insideFunctionSpecifics: options.insideFunctionSpecifics,
|
|
15
|
+
params,
|
|
16
|
+
});
|
|
18
17
|
try {
|
|
19
18
|
const progress = await (0, progress_1.getProgress)({
|
|
20
|
-
bucketName:
|
|
21
|
-
renderId:
|
|
19
|
+
bucketName: params.bucketName,
|
|
20
|
+
renderId: params.renderId,
|
|
22
21
|
expectedBucketOwner: options.expectedBucketOwner,
|
|
23
22
|
region: options.providerSpecifics.getCurrentRegionInFunction(),
|
|
24
|
-
memorySizeInMb:
|
|
23
|
+
memorySizeInMb: options.insideFunctionSpecifics.getCurrentMemorySizeInMb(),
|
|
25
24
|
timeoutInMilliseconds: options.timeoutInMilliseconds,
|
|
26
|
-
customCredentials: (_a =
|
|
25
|
+
customCredentials: (_a = params.s3OutputProvider) !== null && _a !== void 0 ? _a : null,
|
|
27
26
|
providerSpecifics: options.providerSpecifics,
|
|
28
|
-
forcePathStyle:
|
|
29
|
-
functionName:
|
|
27
|
+
forcePathStyle: params.forcePathStyle,
|
|
28
|
+
functionName: options.insideFunctionSpecifics.getCurrentFunctionName(),
|
|
30
29
|
});
|
|
31
30
|
return progress;
|
|
32
31
|
}
|
|
@@ -38,11 +37,15 @@ const progressHandler = async (lambdaParams, options) => {
|
|
|
38
37
|
await new Promise((resolve) => {
|
|
39
38
|
setTimeout(resolve, 1000);
|
|
40
39
|
});
|
|
41
|
-
return (0, exports.progressHandler)(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
return (0, exports.progressHandler)({
|
|
41
|
+
params,
|
|
42
|
+
options: {
|
|
43
|
+
expectedBucketOwner: options.expectedBucketOwner,
|
|
44
|
+
timeoutInMilliseconds: options.timeoutInMilliseconds,
|
|
45
|
+
retriesRemaining: options.retriesRemaining - 1,
|
|
46
|
+
providerSpecifics: options.providerSpecifics,
|
|
47
|
+
insideFunctionSpecifics: options.insideFunctionSpecifics,
|
|
48
|
+
},
|
|
46
49
|
});
|
|
47
50
|
}
|
|
48
51
|
throw err;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ServerlessPayload } from '../constants';
|
|
2
|
-
import type { ProviderSpecifics } from '../provider-implementation';
|
|
2
|
+
import type { InsideFunctionSpecifics, ProviderSpecifics } from '../provider-implementation';
|
|
3
3
|
import type { OnStream } from '../streaming/streaming';
|
|
4
4
|
import type { CloudProvider } from '../types';
|
|
5
5
|
type Options = {
|
|
@@ -11,12 +11,13 @@ export type RequestContext = {
|
|
|
11
11
|
getRemainingTimeInMillis: () => number;
|
|
12
12
|
awsRequestId: string;
|
|
13
13
|
};
|
|
14
|
-
export declare const rendererHandler: <Provider extends CloudProvider>({ onStream, options, params, providerSpecifics, requestContext, }: {
|
|
14
|
+
export declare const rendererHandler: <Provider extends CloudProvider>({ onStream, options, params, providerSpecifics, requestContext, insideFunctionSpecifics, }: {
|
|
15
15
|
params: ServerlessPayload<Provider>;
|
|
16
16
|
options: Options;
|
|
17
17
|
onStream: OnStream<Provider>;
|
|
18
18
|
requestContext: RequestContext;
|
|
19
19
|
providerSpecifics: ProviderSpecifics<Provider>;
|
|
20
|
+
insideFunctionSpecifics: InsideFunctionSpecifics;
|
|
20
21
|
}) => Promise<{
|
|
21
22
|
type: "success";
|
|
22
23
|
}>;
|
|
@@ -17,8 +17,8 @@ const on_downloads_helpers_1 = require("../on-downloads-helpers");
|
|
|
17
17
|
const serialize_artifact_1 = require("../serialize-artifact");
|
|
18
18
|
const truthy_1 = require("../truthy");
|
|
19
19
|
const why_is_node_running_1 = require("../why-is-node-running");
|
|
20
|
-
const
|
|
21
|
-
const renderHandler = async ({ params, options, logs, onStream, providerSpecifics, }) => {
|
|
20
|
+
const write_error_to_storage_1 = require("../write-error-to-storage");
|
|
21
|
+
const renderHandler = async ({ params, options, logs, onStream, providerSpecifics, insideFunctionSpecifics, }) => {
|
|
22
22
|
if (params.type !== constants_1.ServerlessRoutines.renderer) {
|
|
23
23
|
throw new Error('Params must be renderer');
|
|
24
24
|
}
|
|
@@ -43,11 +43,12 @@ const renderHandler = async ({ params, options, logs, onStream, providerSpecific
|
|
|
43
43
|
providerSpecifics,
|
|
44
44
|
forcePathStyle: params.forcePathStyle,
|
|
45
45
|
});
|
|
46
|
-
const browserInstance = await
|
|
46
|
+
const browserInstance = await insideFunctionSpecifics.getBrowserInstance({
|
|
47
47
|
logLevel: params.logLevel,
|
|
48
48
|
indent: false,
|
|
49
49
|
chromiumOptions: params.chromiumOptions,
|
|
50
50
|
providerSpecifics,
|
|
51
|
+
insideFunctionSpecifics,
|
|
51
52
|
});
|
|
52
53
|
const outputPath = renderer_1.RenderInternals.tmpDir('remotion-render-');
|
|
53
54
|
if (typeof params.chunk !== 'number') {
|
|
@@ -228,9 +229,9 @@ const renderHandler = async ({ params, options, logs, onStream, providerSpecific
|
|
|
228
229
|
})
|
|
229
230
|
.catch((err) => reject(err));
|
|
230
231
|
});
|
|
231
|
-
const streamTimer =
|
|
232
|
+
const streamTimer = insideFunctionSpecifics.timer('Streaming chunk to the main function', params.logLevel);
|
|
232
233
|
if (audioOutputLocation) {
|
|
233
|
-
const audioChunkTimer =
|
|
234
|
+
const audioChunkTimer = insideFunctionSpecifics.timer('Sending audio chunk', params.logLevel);
|
|
234
235
|
await onStream({
|
|
235
236
|
type: 'audio-chunk-rendered',
|
|
236
237
|
payload: node_fs_1.default.readFileSync(audioOutputLocation),
|
|
@@ -238,7 +239,7 @@ const renderHandler = async ({ params, options, logs, onStream, providerSpecific
|
|
|
238
239
|
audioChunkTimer.end();
|
|
239
240
|
}
|
|
240
241
|
if (videoOutputLocation) {
|
|
241
|
-
const videoChunkTimer =
|
|
242
|
+
const videoChunkTimer = insideFunctionSpecifics.timer('Sending main chunk', params.logLevel);
|
|
242
243
|
await onStream({
|
|
243
244
|
type: pure_1.NoReactAPIs.isAudioCodec(params.codec)
|
|
244
245
|
? 'audio-chunk-rendered'
|
|
@@ -268,7 +269,7 @@ const renderHandler = async ({ params, options, logs, onStream, providerSpecific
|
|
|
268
269
|
return {};
|
|
269
270
|
};
|
|
270
271
|
const ENABLE_SLOW_LEAK_DETECTION = false;
|
|
271
|
-
const rendererHandler = async ({ onStream, options, params, providerSpecifics, requestContext, }) => {
|
|
272
|
+
const rendererHandler = async ({ onStream, options, params, providerSpecifics, requestContext, insideFunctionSpecifics, }) => {
|
|
272
273
|
if (params.type !== constants_1.ServerlessRoutines.renderer) {
|
|
273
274
|
throw new Error('Params must be renderer');
|
|
274
275
|
}
|
|
@@ -282,6 +283,7 @@ const rendererHandler = async ({ onStream, options, params, providerSpecifics, r
|
|
|
282
283
|
logs,
|
|
283
284
|
onStream,
|
|
284
285
|
providerSpecifics,
|
|
286
|
+
insideFunctionSpecifics,
|
|
285
287
|
});
|
|
286
288
|
return {
|
|
287
289
|
type: 'success',
|
|
@@ -316,7 +318,7 @@ const rendererHandler = async ({ onStream, options, params, providerSpecifics, r
|
|
|
316
318
|
frame: null,
|
|
317
319
|
type: 'renderer',
|
|
318
320
|
isFatal: !shouldRetry,
|
|
319
|
-
tmpDir: (0,
|
|
321
|
+
tmpDir: (0, write_error_to_storage_1.getTmpDirStateIfENoSp)(err.stack, providerSpecifics),
|
|
320
322
|
attempt: params.attempt,
|
|
321
323
|
totalAttempts: params.retriesLeft + params.attempt,
|
|
322
324
|
willRetry: shouldRetry,
|
|
@@ -327,11 +329,11 @@ const rendererHandler = async ({ onStream, options, params, providerSpecifics, r
|
|
|
327
329
|
}
|
|
328
330
|
finally {
|
|
329
331
|
if (shouldKeepBrowserOpen) {
|
|
330
|
-
|
|
332
|
+
insideFunctionSpecifics.forgetBrowserEventLoop(params.logLevel);
|
|
331
333
|
}
|
|
332
334
|
else {
|
|
333
|
-
renderer_1.RenderInternals.Log.info({ indent: false, logLevel: params.logLevel }, '
|
|
334
|
-
renderer_1.RenderInternals.Log.info({ indent: false, logLevel: params.logLevel }, 'Quitting
|
|
335
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel: params.logLevel }, 'Function did not succeed with flaky error, not keeping browser open.');
|
|
336
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel: params.logLevel }, 'Quitting Function forcefully now to force not keeping the Function warm.');
|
|
335
337
|
process.exit(0);
|
|
336
338
|
}
|
|
337
339
|
if (ENABLE_SLOW_LEAK_DETECTION) {
|
package/dist/handlers/start.d.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import type { ServerlessPayload } from '../constants';
|
|
2
|
-
import type { ProviderSpecifics } from '../provider-implementation';
|
|
2
|
+
import type { InsideFunctionSpecifics, ProviderSpecifics } from '../provider-implementation';
|
|
3
3
|
import type { CloudProvider } from '../types';
|
|
4
4
|
type Options = {
|
|
5
5
|
expectedBucketOwner: string;
|
|
6
6
|
timeoutInMilliseconds: number;
|
|
7
7
|
renderId: string;
|
|
8
8
|
};
|
|
9
|
-
export declare const startHandler: <Provider extends CloudProvider>(params
|
|
9
|
+
export declare const startHandler: <Provider extends CloudProvider>({ params, options, providerSpecifics, insideFunctionSpecifics, }: {
|
|
10
|
+
params: ServerlessPayload<Provider>;
|
|
11
|
+
options: Options;
|
|
12
|
+
providerSpecifics: ProviderSpecifics<Provider>;
|
|
13
|
+
insideFunctionSpecifics: InsideFunctionSpecifics;
|
|
14
|
+
}) => Promise<{
|
|
10
15
|
type: "success";
|
|
11
16
|
bucketName: string;
|
|
12
17
|
renderId: string;
|
package/dist/handlers/start.js
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.startHandler = void 0;
|
|
4
|
-
const version_1 = require("remotion/version");
|
|
5
4
|
const constants_1 = require("../constants");
|
|
6
5
|
const get_or_create_bucket_1 = require("../get-or-create-bucket");
|
|
7
6
|
const overall_render_progress_1 = require("../overall-render-progress");
|
|
8
|
-
const
|
|
7
|
+
const check_version_mismatch_1 = require("./check-version-mismatch");
|
|
8
|
+
const startHandler = async ({ params, options, providerSpecifics, insideFunctionSpecifics, }) => {
|
|
9
9
|
var _a, _b, _c, _d;
|
|
10
10
|
if (params.type !== constants_1.ServerlessRoutines.start) {
|
|
11
11
|
throw new TypeError('Expected type start');
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
13
|
+
(0, check_version_mismatch_1.checkVersionMismatch)({
|
|
14
|
+
apiName: 'renderMediaOnLambda()',
|
|
15
|
+
insideFunctionSpecifics,
|
|
16
|
+
params,
|
|
17
|
+
});
|
|
19
18
|
const region = providerSpecifics.getCurrentRegionInFunction();
|
|
20
19
|
const bucketName = (_a = params.bucketName) !== null && _a !== void 0 ? _a : (await (0, get_or_create_bucket_1.internalGetOrCreateBucket)({
|
|
21
20
|
region: providerSpecifics.getCurrentRegionInFunction(),
|
|
@@ -44,7 +43,7 @@ const startHandler = async (params, options, providerSpecifics) => {
|
|
|
44
43
|
});
|
|
45
44
|
const payload = {
|
|
46
45
|
type: constants_1.ServerlessRoutines.launch,
|
|
47
|
-
|
|
46
|
+
framesPerFunction: params.framesPerLambda,
|
|
48
47
|
composition: params.composition,
|
|
49
48
|
serveUrl: realServeUrl,
|
|
50
49
|
inputProps: params.inputProps,
|
|
@@ -68,7 +67,7 @@ const startHandler = async (params, options, providerSpecifics) => {
|
|
|
68
67
|
scale: params.scale,
|
|
69
68
|
numberOfGifLoops: params.numberOfGifLoops,
|
|
70
69
|
everyNthFrame: params.everyNthFrame,
|
|
71
|
-
|
|
70
|
+
concurrencyPerFunction: params.concurrencyPerLambda,
|
|
72
71
|
downloadBehavior: params.downloadBehavior,
|
|
73
72
|
muted: params.muted,
|
|
74
73
|
overwrite: params.overwrite,
|
|
@@ -89,7 +88,7 @@ const startHandler = async (params, options, providerSpecifics) => {
|
|
|
89
88
|
metadata: params.metadata,
|
|
90
89
|
};
|
|
91
90
|
await providerSpecifics.callFunctionAsync({
|
|
92
|
-
functionName:
|
|
91
|
+
functionName: insideFunctionSpecifics.getCurrentFunctionName(),
|
|
93
92
|
type: constants_1.ServerlessRoutines.launch,
|
|
94
93
|
payload,
|
|
95
94
|
region,
|
package/dist/handlers/still.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ServerlessPayload } from '../constants';
|
|
2
|
-
import type { ProviderSpecifics } from '../provider-implementation';
|
|
2
|
+
import type { InsideFunctionSpecifics, ProviderSpecifics } from '../provider-implementation';
|
|
3
3
|
import type { OnStream } from '../streaming/streaming';
|
|
4
4
|
import type { CloudProvider } from '../types';
|
|
5
5
|
type Options<Provider extends CloudProvider> = {
|
|
@@ -9,6 +9,7 @@ type Options<Provider extends CloudProvider> = {
|
|
|
9
9
|
onStream: OnStream<Provider>;
|
|
10
10
|
timeoutInMilliseconds: number;
|
|
11
11
|
providerSpecifics: ProviderSpecifics<Provider>;
|
|
12
|
+
insideFunctionSpecifics: InsideFunctionSpecifics;
|
|
12
13
|
};
|
|
13
14
|
export declare const stillHandler: <Provider extends CloudProvider>(options: Options<Provider>) => Promise<{
|
|
14
15
|
type: "success";
|