@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.
Files changed (78) hide show
  1. package/.turbo/turbo-make.log +1 -1
  2. package/dist/best-frames-per-function-param.js +5 -5
  3. package/dist/client.d.ts +9 -0
  4. package/dist/client.js +30 -12
  5. package/dist/compress-props.d.ts +6 -2
  6. package/dist/compress-props.js +5 -3
  7. package/dist/concat-videos.d.ts +3 -4
  8. package/dist/concat-videos.js +2 -2
  9. package/dist/constants.d.ts +39 -3
  10. package/dist/constants.js +8 -1
  11. package/dist/create-post-render-data.d.ts +1 -1
  12. package/dist/create-post-render-data.js +2 -2
  13. package/dist/estimate-price-from-bucket.d.ts +2 -2
  14. package/dist/estimate-price-from-bucket.js +4 -4
  15. package/dist/expected-out-name.d.ts +1 -1
  16. package/dist/get-browser-instance.d.ts +5 -12
  17. package/dist/get-browser-instance.js +8 -7
  18. package/dist/get-custom-out-name.d.ts +1 -1
  19. package/dist/get-or-create-bucket.d.ts +1 -1
  20. package/dist/handlers/check-version-mismatch.d.ts +8 -0
  21. package/dist/handlers/check-version-mismatch.js +23 -0
  22. package/dist/handlers/compositions.d.ts +7 -2
  23. package/dist/handlers/compositions.js +25 -25
  24. package/dist/handlers/launch.d.ts +3 -2
  25. package/dist/handlers/launch.js +30 -31
  26. package/dist/handlers/progress.d.ts +6 -2
  27. package/dist/handlers/progress.js +23 -20
  28. package/dist/handlers/renderer.d.ts +3 -2
  29. package/dist/handlers/renderer.js +13 -11
  30. package/dist/handlers/start.d.ts +7 -2
  31. package/dist/handlers/start.js +10 -11
  32. package/dist/handlers/still.d.ts +2 -1
  33. package/dist/handlers/still.js +68 -67
  34. package/dist/index.d.ts +21 -5
  35. package/dist/index.js +54 -7
  36. package/dist/info.d.ts +1 -1
  37. package/dist/inner-routine.d.ts +22 -0
  38. package/dist/inner-routine.js +267 -0
  39. package/dist/inspect-error.d.ts +2 -2
  40. package/dist/invoke-webhook.d.ts +14 -11
  41. package/dist/invoke-webhook.js +1 -1
  42. package/dist/is-warm.d.ts +2 -0
  43. package/dist/is-warm.js +10 -0
  44. package/dist/make-bucket-name.d.ts +1 -1
  45. package/dist/make-timeout-error.d.ts +1 -1
  46. package/dist/make-timeout-message.js +3 -2
  47. package/dist/merge-chunks.d.ts +2 -1
  48. package/dist/merge-chunks.js +3 -3
  49. package/dist/most-expensive-chunks.d.ts +2 -2
  50. package/dist/most-expensive-chunks.js +1 -1
  51. package/dist/overall-render-progress.d.ts +3 -3
  52. package/dist/plan-frame-ranges.d.ts +2 -2
  53. package/dist/plan-frame-ranges.js +4 -4
  54. package/dist/print-logging-grep-helper.d.ts +4 -0
  55. package/dist/print-logging-grep-helper.js +12 -0
  56. package/dist/progress.js +2 -2
  57. package/dist/provider-implementation.d.ts +152 -3
  58. package/dist/render-metadata.d.ts +1 -1
  59. package/dist/render-progress.d.ts +1 -1
  60. package/dist/streaming/streaming.d.ts +6 -6
  61. package/dist/streaming/streaming.js +3 -3
  62. package/dist/types.d.ts +3 -2
  63. package/dist/validate-composition.d.ts +1 -1
  64. package/dist/validate-composition.js +11 -1
  65. package/dist/validate-frames-per-function.d.ts +2 -2
  66. package/dist/validate-frames-per-function.js +13 -13
  67. package/dist/{write-lambda-error.d.ts → write-error-to-storage.d.ts} +4 -4
  68. package/package.json +6 -5
  69. package/tsconfig.tsbuildinfo +1 -1
  70. package/.turbo/turbo-formatting.log +0 -7
  71. package/.turbo/turbo-lint.log +0 -11
  72. package/dist/compositions.d.ts +0 -11
  73. package/dist/compositions.js +0 -82
  74. package/dist/still.d.ts +0 -28
  75. package/dist/still.js +0 -2
  76. package/dist/validate-frames-per-lambda.d.ts +0 -4
  77. package/dist/validate-frames-per-lambda.js +0 -29
  78. /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";
@@ -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 write_lambda_error_1 = require("../write-lambda-error");
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 = providerSpecifics.getBrowserInstance({
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 Lambda');
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.concurrencyPerLambda,
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.framesPerLambda) !== null && _c !== void 0 ? _c : (0, best_frames_per_function_param_1.bestFramesPerFunctionParam)(frameCount.length);
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)('video-or-audio', [
121
- serializedResolved.length,
122
- params.inputProps.type === 'bucket-url'
123
- ? params.inputProps.hash.length
124
- : params.inputProps.payload.length,
125
- JSON.stringify(params.envVariables).length,
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.concurrencyPerLambda,
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: Number(process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE),
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: process.env.AWS_LAMBDA_FUNCTION_NAME,
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 = providerSpecifics.timer('Checking if output file already exists', params.logLevel);
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 : process.env.AWS_LAMBDA_FUNCTION_NAME;
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, write_lambda_error_1.getTmpDirStateIfENoSp)(err.stack, providerSpecifics),
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
- providerSpecifics.forgetBrowserEventLoop(params.logLevel);
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>(lambdaParams: ServerlessPayload<Provider>, options: Options<Provider>) => Promise<GenericRenderProgress<Provider>>;
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 progressHandler = async (lambdaParams, options) => {
6
+ const check_version_mismatch_1 = require("./check-version-mismatch");
7
+ const progressHandler = async ({ params, options, }) => {
8
8
  var _a;
9
- if (lambdaParams.type !== constants_1.ServerlessRoutines.status) {
9
+ if (params.type !== constants_1.ServerlessRoutines.status) {
10
10
  throw new TypeError('Expected status type');
11
11
  }
12
- if (lambdaParams.version !== version_1.VERSION) {
13
- if (!lambdaParams.version) {
14
- throw new Error(`Version mismatch: When calling getRenderProgress(), you called the function ${process.env.AWS_LAMBDA_FUNCTION_NAME} which has the version ${version_1.VERSION} but the @remotion/lambda package is an older version. Deploy a new function and use it to call getRenderProgress(). See: https://www.remotion.dev/docs/lambda/upgrading`);
15
- }
16
- throw new Error(`Version mismatch: When calling getRenderProgress(), you passed ${process.env.AWS_LAMBDA_FUNCTION_NAME} as the function, which has the version ${version_1.VERSION}, but the @remotion/lambda package you used to invoke the function has version ${lambdaParams.version}. Deploy a new function and use it to call getRenderProgress(). See: https://www.remotion.dev/docs/lambda/upgrading`);
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: lambdaParams.bucketName,
21
- renderId: lambdaParams.renderId,
19
+ bucketName: params.bucketName,
20
+ renderId: params.renderId,
22
21
  expectedBucketOwner: options.expectedBucketOwner,
23
22
  region: options.providerSpecifics.getCurrentRegionInFunction(),
24
- memorySizeInMb: Number(process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE),
23
+ memorySizeInMb: options.insideFunctionSpecifics.getCurrentMemorySizeInMb(),
25
24
  timeoutInMilliseconds: options.timeoutInMilliseconds,
26
- customCredentials: (_a = lambdaParams.s3OutputProvider) !== null && _a !== void 0 ? _a : null,
25
+ customCredentials: (_a = params.s3OutputProvider) !== null && _a !== void 0 ? _a : null,
27
26
  providerSpecifics: options.providerSpecifics,
28
- forcePathStyle: lambdaParams.forcePathStyle,
29
- functionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
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)(lambdaParams, {
42
- expectedBucketOwner: options.expectedBucketOwner,
43
- timeoutInMilliseconds: options.timeoutInMilliseconds,
44
- retriesRemaining: options.retriesRemaining - 1,
45
- providerSpecifics: options.providerSpecifics,
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 write_lambda_error_1 = require("../write-lambda-error");
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 providerSpecifics.getBrowserInstance({
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 = providerSpecifics.timer('Streaming chunk to the main function', params.logLevel);
232
+ const streamTimer = insideFunctionSpecifics.timer('Streaming chunk to the main function', params.logLevel);
232
233
  if (audioOutputLocation) {
233
- const audioChunkTimer = providerSpecifics.timer('Sending audio chunk', params.logLevel);
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 = providerSpecifics.timer('Sending main chunk', params.logLevel);
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, write_lambda_error_1.getTmpDirStateIfENoSp)(err.stack, providerSpecifics),
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
- providerSpecifics.forgetBrowserEventLoop(params.logLevel);
332
+ insideFunctionSpecifics.forgetBrowserEventLoop(params.logLevel);
331
333
  }
332
334
  else {
333
- renderer_1.RenderInternals.Log.info({ indent: false, logLevel: params.logLevel }, 'Lambda did not succeed with flaky error, not keeping browser open.');
334
- renderer_1.RenderInternals.Log.info({ indent: false, logLevel: params.logLevel }, 'Quitting Lambda forcefully now to force not keeping the Lambda warm.');
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) {
@@ -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: ServerlessPayload<Provider>, options: Options, providerSpecifics: ProviderSpecifics<Provider>) => Promise<{
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;
@@ -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 startHandler = async (params, options, providerSpecifics) => {
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
- if (params.version !== version_1.VERSION) {
14
- if (!params.version) {
15
- throw new Error(`Version mismatch: When calling renderMediaOnLambda(), you called the function ${process.env.AWS_LAMBDA_FUNCTION_NAME} which has the version ${version_1.VERSION} but the @remotion/lambda package is an older version. Deploy a new function and use it to call renderMediaOnLambda(). See: https://www.remotion.dev/docs/lambda/upgrading`);
16
- }
17
- throw new Error(`Version mismatch: When calling renderMediaOnLambda(), you passed ${process.env.AWS_LAMBDA_FUNCTION_NAME} as the function, which has the version ${version_1.VERSION}, but the @remotion/lambda package you used to invoke the function has version ${params.version}. Deploy a new function and use it to call renderMediaOnLambda(). See: https://www.remotion.dev/docs/lambda/upgrading`);
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
- framesPerLambda: params.framesPerLambda,
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
- concurrencyPerLambda: params.concurrencyPerLambda,
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: providerSpecifics.getCurrentFunctionName(),
91
+ functionName: insideFunctionSpecifics.getCurrentFunctionName(),
93
92
  type: constants_1.ServerlessRoutines.launch,
94
93
  payload,
95
94
  region,
@@ -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";