@remotion/lambda 4.0.8 → 4.0.10

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.
@@ -26,7 +26,9 @@ const getCompositionsOnLambda = async ({ chromiumOptions, serveUrl, region, inpu
26
26
  region,
27
27
  userSpecifiedBucketName: bucketName !== null && bucketName !== void 0 ? bucketName : null,
28
28
  propsType: 'input-props',
29
- needsToUpload: (0, compress_props_1.getNeedsToUpload)('video-or-audio', stringifiedInputProps),
29
+ needsToUpload: (0, compress_props_1.getNeedsToUpload)('video-or-audio', [
30
+ stringifiedInputProps.length,
31
+ ]),
30
32
  });
31
33
  try {
32
34
  const res = await (0, call_lambda_1.callLambda)({
@@ -23,7 +23,9 @@ const makeLambdaRenderMediaPayload = async ({ rendererFunctionName, frameRange,
23
23
  const serialized = await (0, compress_props_1.compressInputProps)({
24
24
  stringifiedInputProps,
25
25
  region,
26
- needsToUpload: (0, compress_props_1.getNeedsToUpload)('video-or-audio', stringifiedInputProps),
26
+ needsToUpload: (0, compress_props_1.getNeedsToUpload)('video-or-audio', [
27
+ stringifiedInputProps.length,
28
+ ]),
27
29
  userSpecifiedBucketName: bucketName !== null && bucketName !== void 0 ? bucketName : null,
28
30
  propsType: 'input-props',
29
31
  });
@@ -31,7 +31,7 @@ const renderStillOnLambda = async ({ functionName, serveUrl, inputProps, imageFo
31
31
  const serializedInputProps = await (0, compress_props_1.compressInputProps)({
32
32
  stringifiedInputProps,
33
33
  region,
34
- needsToUpload: (0, compress_props_1.getNeedsToUpload)('still', stringifiedInputProps),
34
+ needsToUpload: (0, compress_props_1.getNeedsToUpload)('still', [stringifiedInputProps.length]),
35
35
  userSpecifiedBucketName: forceBucketName !== null && forceBucketName !== void 0 ? forceBucketName : null,
36
36
  propsType: 'input-props',
37
37
  });
package/dist/cli/log.d.ts CHANGED
@@ -2,24 +2,24 @@ export declare const Log: {
2
2
  verbose: (message?: any, ...optionalParams: any[]) => void;
3
3
  verboseAdvanced: (options: {
4
4
  indent: boolean;
5
- logLevel: "error" | "verbose" | "info" | "warn";
5
+ logLevel: "verbose" | "info" | "warn" | "error";
6
6
  } & {
7
7
  tag?: string | undefined;
8
8
  }, message?: any, ...optionalParams: any[]) => void;
9
9
  info: (message?: any, ...optionalParams: any[]) => void;
10
10
  infoAdvanced: (options: {
11
11
  indent: boolean;
12
- logLevel: "error" | "verbose" | "info" | "warn";
12
+ logLevel: "verbose" | "info" | "warn" | "error";
13
13
  }, message?: any, ...optionalParams: any[]) => void;
14
14
  warn: (message?: any, ...optionalParams: any[]) => void;
15
15
  warnAdvanced: (options: {
16
16
  indent: boolean;
17
- logLevel: "error" | "verbose" | "info" | "warn";
17
+ logLevel: "verbose" | "info" | "warn" | "error";
18
18
  }, message?: any, ...optionalParams: any[]) => void;
19
19
  error: (message?: any, ...optionalParams: any[]) => void;
20
20
  errorAdvanced: (options: {
21
21
  indent: boolean;
22
- logLevel: "error" | "verbose" | "info" | "warn";
22
+ logLevel: "verbose" | "info" | "warn" | "error";
23
23
  } & {
24
24
  tag?: string | undefined;
25
25
  }, message?: any, ...optionalParams: any[]) => void;
@@ -3,5 +3,8 @@ export declare const planFrameRanges: ({ framesPerLambda, frameRange, everyNthFr
3
3
  frameRange: [number, number];
4
4
  everyNthFrame: number;
5
5
  }) => {
6
- chunks: [number, number][];
6
+ chunks: [
7
+ number,
8
+ number
9
+ ][];
7
10
  };
@@ -1 +1 @@
1
- export declare const getCurrentRegionInFunction: () => "eu-central-1" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "eu-north-1" | "us-east-1" | "us-east-2" | "us-west-1" | "us-west-2" | "ap-south-1" | "ap-southeast-1" | "ap-southeast-2" | "ap-northeast-1" | "ap-northeast-2" | "ap-northeast-3" | "ca-central-1" | "sa-east-1" | "eu-south-1" | "af-south-1" | "ap-east-1" | "me-south-1";
1
+ export declare const getCurrentRegionInFunction: () => "eu-central-1" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "eu-south-1" | "eu-north-1" | "us-east-1" | "us-east-2" | "us-west-1" | "us-west-2" | "af-south-1" | "ap-south-1" | "ap-east-1" | "ap-southeast-1" | "ap-southeast-2" | "ap-northeast-1" | "ap-northeast-2" | "ap-northeast-3" | "ca-central-1" | "me-south-1" | "sa-east-1";
@@ -191,7 +191,12 @@ const innerLaunchHandler = async (params, options) => {
191
191
  const sortedChunks = chunks.slice().sort((a, b) => a[0] - b[0]);
192
192
  const reqSend = (0, timer_1.timer)('sending off requests');
193
193
  const serializedResolved = (0, compress_props_1.serializeOrThrow)(comp.props, 'resolved-props');
194
- const needsToUpload = (0, compress_props_1.getNeedsToUpload)('video-or-audio', serializedResolved + params.inputProps);
194
+ const needsToUpload = (0, compress_props_1.getNeedsToUpload)('video-or-audio', [
195
+ serializedResolved.length,
196
+ params.inputProps.type === 'bucket-url'
197
+ ? params.inputProps.hash.length
198
+ : params.inputProps.payload.length,
199
+ ]);
195
200
  const serializedResolvedProps = await (0, compress_props_1.compressInputProps)({
196
201
  propsType: 'resolved-props',
197
202
  region: (0, get_current_region_1.getCurrentRegionInFunction)(),
@@ -2,7 +2,7 @@ import type { AwsRegion } from '../client';
2
2
  import type { SerializedInputProps } from './constants';
3
3
  type PropsType = 'input-props' | 'resolved-props';
4
4
  export declare const serializeOrThrow: (inputProps: Record<string, unknown>, propsType: PropsType) => string;
5
- export declare const getNeedsToUpload: (type: 'still' | 'video-or-audio', stringifiedInputProps: string) => boolean;
5
+ export declare const getNeedsToUpload: (type: 'still' | 'video-or-audio', sizes: number[]) => boolean;
6
6
  export declare const compressInputProps: ({ stringifiedInputProps, region, userSpecifiedBucketName, propsType, needsToUpload, }: {
7
7
  stringifiedInputProps: string;
8
8
  region: AwsRegion;
@@ -21,10 +21,12 @@ const serializeOrThrow = (inputProps, propsType) => {
21
21
  }
22
22
  };
23
23
  exports.serializeOrThrow = serializeOrThrow;
24
- const getNeedsToUpload = (type, stringifiedInputProps) => {
25
- const MAX_INLINE_PAYLOAD_SIZE = type === 'still' ? 5000000 : 200000;
26
- if (stringifiedInputProps.length > MAX_INLINE_PAYLOAD_SIZE) {
27
- console.warn(`Warning: The props are over ${Math.round(MAX_INLINE_PAYLOAD_SIZE / 1000)}KB (${Math.ceil(stringifiedInputProps.length / 1024)}KB) in size. Uploading them to S3 to circumvent AWS Lambda payload size, which may lead to slowdown.`);
24
+ const getNeedsToUpload = (type, sizes) => {
25
+ const MARGIN = 5000;
26
+ const MAX_INLINE_PAYLOAD_SIZE = (type === 'still' ? 5000000 : 200000) - MARGIN;
27
+ const sizesAlreadyUsed = sizes.reduce((a, b) => a + b);
28
+ if (sizesAlreadyUsed > MAX_INLINE_PAYLOAD_SIZE) {
29
+ console.warn(`Warning: The props are over ${Math.round(MAX_INLINE_PAYLOAD_SIZE / 1000)}KB (${Math.ceil(sizesAlreadyUsed / 1024)}KB) in size. Uploading them to S3 to circumvent AWS Lambda payload size, which may lead to slowdown.`);
28
30
  return true;
29
31
  }
30
32
  return false;
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import https from 'https';
4
2
  import http from 'node:http';
5
3
  import type { EnhancedErrorInfo } from '../functions/helpers/write-lambda-error';
@@ -38,9 +36,10 @@ export declare const mockableHttpClients: {
38
36
  http: typeof http.request;
39
37
  https: typeof https.request;
40
38
  };
41
- export declare function invokeWebhook({ payload, secret, url, }: {
39
+ type InvokeWebhookOptions = {
42
40
  payload: WebhookPayload;
43
41
  url: string;
44
42
  secret: string | null;
45
- }): Promise<void>;
43
+ };
44
+ export declare const invokeWebhook: (options: InvokeWebhookOptions, retries?: number, errors?: number) => Promise<void>;
46
45
  export {};
@@ -27,6 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.invokeWebhook = exports.mockableHttpClients = exports.calculateSignature = void 0;
30
+ const renderer_1 = require("@remotion/renderer");
30
31
  const https_1 = __importDefault(require("https"));
31
32
  const Crypto = __importStar(require("node:crypto"));
32
33
  const node_http_1 = __importDefault(require("node:http"));
@@ -59,7 +60,7 @@ exports.mockableHttpClients = {
59
60
  http: node_http_1.default.request,
60
61
  https: https_1.default.request,
61
62
  };
62
- function invokeWebhook({ payload, secret, url, }) {
63
+ function invokeWebhookRaw({ payload, secret, url, }) {
63
64
  const jsonPayload = JSON.stringify(payload);
64
65
  return new Promise((resolve, reject) => {
65
66
  const req = getWebhookClient(url)(url, {
@@ -86,4 +87,26 @@ function invokeWebhook({ payload, secret, url, }) {
86
87
  req.end();
87
88
  });
88
89
  }
90
+ function exponentialBackoff(errorCount) {
91
+ return 1000 * 2 ** (errorCount - 1);
92
+ }
93
+ const invokeWebhook = async (options, retries = 2, errors = 0) => {
94
+ try {
95
+ await invokeWebhookRaw(options);
96
+ }
97
+ catch (err) {
98
+ if (retries === 0) {
99
+ throw err;
100
+ }
101
+ renderer_1.RenderInternals.Log.error('Could not send webhook due to error:');
102
+ renderer_1.RenderInternals.Log.error(err.stack);
103
+ renderer_1.RenderInternals.Log.error(`Retrying in ${exponentialBackoff(errors)}ms.`);
104
+ await new Promise((resolve) => {
105
+ setTimeout(() => {
106
+ resolve();
107
+ }, exponentialBackoff(errors));
108
+ });
109
+ return (0, exports.invokeWebhook)(options, retries - 1, errors + 1);
110
+ }
111
+ };
89
112
  exports.invokeWebhook = invokeWebhook;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/lambda",
3
- "version": "4.0.8",
3
+ "version": "4.0.10",
4
4
  "description": "Distributed renderer for Remotion based on AWS Lambda",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,
@@ -26,10 +26,10 @@
26
26
  "aws-policies": "^1.0.1",
27
27
  "mime-types": "2.1.34",
28
28
  "zod": "3.21.4",
29
- "@remotion/bundler": "4.0.8",
30
- "@remotion/renderer": "4.0.8",
31
- "remotion": "4.0.8",
32
- "@remotion/cli": "4.0.8"
29
+ "@remotion/bundler": "4.0.10",
30
+ "@remotion/cli": "4.0.10",
31
+ "remotion": "4.0.10",
32
+ "@remotion/renderer": "4.0.10"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@jonny/eslint-config": "3.0.266",
@@ -44,11 +44,11 @@
44
44
  "typescript": "4.9.5",
45
45
  "vitest": "0.31.1",
46
46
  "zip-lib": "^0.7.2",
47
- "@remotion/bundler": "4.0.8",
48
- "@remotion/compositor-linux-arm64-gnu": "4.0.8"
47
+ "@remotion/bundler": "4.0.10",
48
+ "@remotion/compositor-linux-arm64-gnu": "4.0.10"
49
49
  },
50
50
  "peerDependencies": {
51
- "@remotion/bundler": "4.0.8"
51
+ "@remotion/bundler": "4.0.10"
52
52
  },
53
53
  "publishConfig": {
54
54
  "access": "public"
Binary file