@remotion/lambda 4.0.35 → 4.0.37

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.
@@ -19,9 +19,9 @@ type LambdaCommandLineOptions = {
19
19
  ['disable-chunk-optimization']: boolean;
20
20
  ['save-browser-logs']: boolean;
21
21
  ['disable-cloudwatch']: boolean;
22
- ['max-retries']: number;
23
- ['frames-per-lambda']: number;
24
- ['concurrency-per-lambda']: number;
22
+ ['max-retries']?: number;
23
+ ['frames-per-lambda']?: number;
24
+ ['concurrency-per-lambda']?: number;
25
25
  ['out-name']: string | undefined;
26
26
  ['custom-role-arn']: string | undefined;
27
27
  privacy: Privacy;
@@ -23,7 +23,7 @@ const log_1 = require("../../log");
23
23
  const progress_1 = require("./progress");
24
24
  exports.RENDER_COMMAND = 'render';
25
25
  const renderCommand = async (args, remotionRoot) => {
26
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
26
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
27
27
  const serveUrl = args[0];
28
28
  if (!serveUrl) {
29
29
  log_1.Log.error('No serve URL passed.');
@@ -113,7 +113,7 @@ const renderCommand = async (args, remotionRoot) => {
113
113
  region,
114
114
  maxRetries,
115
115
  composition,
116
- framesPerLambda,
116
+ framesPerLambda: framesPerLambda !== null && framesPerLambda !== void 0 ? framesPerLambda : null,
117
117
  privacy,
118
118
  logLevel,
119
119
  frameRange: frameRange !== null && frameRange !== void 0 ? frameRange : null,
@@ -123,7 +123,7 @@ const renderCommand = async (args, remotionRoot) => {
123
123
  scale,
124
124
  numberOfGifLoops,
125
125
  everyNthFrame,
126
- concurrencyPerLambda: args_1.parsedLambdaCli['concurrency-per-lambda'],
126
+ concurrencyPerLambda: (_g = args_1.parsedLambdaCli['concurrency-per-lambda']) !== null && _g !== void 0 ? _g : 1,
127
127
  muted,
128
128
  overwrite,
129
129
  audioBitrate,
@@ -133,12 +133,12 @@ const renderCommand = async (args, remotionRoot) => {
133
133
  webhook: args_1.parsedLambdaCli.webhook
134
134
  ? {
135
135
  url: args_1.parsedLambdaCli.webhook,
136
- secret: (_g = args_1.parsedLambdaCli['webhook-secret']) !== null && _g !== void 0 ? _g : null,
136
+ secret: (_h = args_1.parsedLambdaCli['webhook-secret']) !== null && _h !== void 0 ? _h : null,
137
137
  customData: webhookCustomData,
138
138
  }
139
139
  : null,
140
- rendererFunctionName: (_h = args_1.parsedLambdaCli['renderer-function-name']) !== null && _h !== void 0 ? _h : null,
141
- forceBucketName: (_j = args_1.parsedLambdaCli['force-bucket-name']) !== null && _j !== void 0 ? _j : null,
140
+ rendererFunctionName: (_j = args_1.parsedLambdaCli['renderer-function-name']) !== null && _j !== void 0 ? _j : null,
141
+ forceBucketName: (_k = args_1.parsedLambdaCli['force-bucket-name']) !== null && _k !== void 0 ? _k : null,
142
142
  audioCodec: cli_1.CliInternals.parsedCli['audio-codec'],
143
143
  deleteAfter: deleteAfter !== null && deleteAfter !== void 0 ? deleteAfter : null,
144
144
  colorSpace,
@@ -0,0 +1,7 @@
1
+ /// <reference types="node" />
2
+ type OnMessage = (type: 'error' | 'success', nonce: string, data: Buffer) => void;
3
+ export declare const makeStreaming: (onMessage: OnMessage) => {
4
+ addData: (data: Buffer) => void;
5
+ };
6
+ export declare const makePayloadMessage: (nonce: number, data: Buffer, status: 0 | 1) => Buffer;
7
+ export {};
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makePayloadMessage = exports.makeStreaming = void 0;
4
+ const makeStreaming = (onMessage) => {
5
+ let outputBuffer = Buffer.from('');
6
+ const separator = Buffer.from('remotion_buffer:');
7
+ let unprocessedBuffers = [];
8
+ let missingData = null;
9
+ const processInput = () => {
10
+ let separatorIndex = outputBuffer.indexOf(separator);
11
+ if (separatorIndex === -1) {
12
+ return;
13
+ }
14
+ separatorIndex += separator.length;
15
+ let nonceString = '';
16
+ let lengthString = '';
17
+ let statusString = '';
18
+ // Each message from Rust is prefixed with `remotion_buffer;{[nonce]}:{[length]}`
19
+ // Let's read the buffer to extract the nonce, and if the full length is available,
20
+ // we'll extract the data and pass it to the callback.
21
+ // eslint-disable-next-line no-constant-condition
22
+ while (true) {
23
+ const nextDigit = outputBuffer[separatorIndex];
24
+ // 0x3a is the character ":"
25
+ if (nextDigit === 0x3a) {
26
+ separatorIndex++;
27
+ break;
28
+ }
29
+ separatorIndex++;
30
+ nonceString += String.fromCharCode(nextDigit);
31
+ }
32
+ // eslint-disable-next-line no-constant-condition
33
+ while (true) {
34
+ const nextDigit = outputBuffer[separatorIndex];
35
+ if (nextDigit === 0x3a) {
36
+ separatorIndex++;
37
+ break;
38
+ }
39
+ separatorIndex++;
40
+ lengthString += String.fromCharCode(nextDigit);
41
+ }
42
+ // eslint-disable-next-line no-constant-condition
43
+ while (true) {
44
+ const nextDigit = outputBuffer[separatorIndex];
45
+ if (nextDigit === 0x3a) {
46
+ break;
47
+ }
48
+ separatorIndex++;
49
+ statusString += String.fromCharCode(nextDigit);
50
+ }
51
+ const length = Number(lengthString);
52
+ const status = Number(statusString);
53
+ const dataLength = outputBuffer.length - separatorIndex - 1;
54
+ if (dataLength < length) {
55
+ missingData = {
56
+ dataMissing: length - dataLength,
57
+ };
58
+ return;
59
+ }
60
+ const data = outputBuffer.subarray(separatorIndex + 1, separatorIndex + 1 + Number(lengthString));
61
+ onMessage(status === 1 ? 'error' : 'success', nonceString, data);
62
+ missingData = null;
63
+ outputBuffer = outputBuffer.subarray(separatorIndex + Number(lengthString) + 1);
64
+ processInput();
65
+ };
66
+ return {
67
+ addData: (data) => {
68
+ unprocessedBuffers.push(data);
69
+ const separatorIndex = data.indexOf(separator);
70
+ if (separatorIndex === -1) {
71
+ if (missingData) {
72
+ missingData.dataMissing -= data.length;
73
+ }
74
+ if (!missingData || missingData.dataMissing > 0) {
75
+ return;
76
+ }
77
+ }
78
+ unprocessedBuffers.unshift(outputBuffer);
79
+ outputBuffer = Buffer.concat(unprocessedBuffers);
80
+ unprocessedBuffers = [];
81
+ processInput();
82
+ },
83
+ };
84
+ };
85
+ exports.makeStreaming = makeStreaming;
86
+ const makePayloadMessage = (nonce, data, status) => {
87
+ const concat = Buffer.concat([
88
+ Buffer.from('remotion_buffer:'),
89
+ Buffer.from(nonce.toString()),
90
+ Buffer.from(':'),
91
+ Buffer.from(data.length.toString()),
92
+ Buffer.from(':'),
93
+ Buffer.from(String(status)),
94
+ Buffer.from(':'),
95
+ data,
96
+ ]);
97
+ return concat;
98
+ };
99
+ exports.makePayloadMessage = makePayloadMessage;
@@ -39,6 +39,9 @@ const isFlakyError = (err) => {
39
39
  if (message.includes('RequestTimeout: Your socket connection to the server')) {
40
40
  return true;
41
41
  }
42
+ if (message.includes('waiting for the page to render the React component failed')) {
43
+ return true;
44
+ }
42
45
  return false;
43
46
  };
44
47
  exports.isFlakyError = isFlakyError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/lambda",
3
- "version": "4.0.35",
3
+ "version": "4.0.37",
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.35",
30
- "@remotion/renderer": "4.0.35",
31
- "remotion": "4.0.35",
32
- "@remotion/cli": "4.0.35"
29
+ "@remotion/bundler": "4.0.37",
30
+ "@remotion/renderer": "4.0.37",
31
+ "@remotion/cli": "4.0.37",
32
+ "remotion": "4.0.37"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@jonny/eslint-config": "3.0.266",
@@ -43,11 +43,11 @@
43
43
  "ts-node": "^10.8.0",
44
44
  "vitest": "0.31.1",
45
45
  "zip-lib": "^0.7.2",
46
- "@remotion/bundler": "4.0.35",
47
- "@remotion/compositor-linux-arm64-gnu": "4.0.35"
46
+ "@remotion/bundler": "4.0.37",
47
+ "@remotion/compositor-linux-arm64-gnu": "4.0.37"
48
48
  },
49
49
  "peerDependencies": {
50
- "@remotion/bundler": "4.0.35"
50
+ "@remotion/bundler": "4.0.37"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"
Binary file
@@ -1,8 +0,0 @@
1
- import type { AwsRegion } from '../client';
2
- import type { SerializedInputProps } from './constants';
3
- export declare const deserializeInputProps: ({ serialized, region, bucketName, expectedBucketOwner, }: {
4
- serialized: SerializedInputProps;
5
- region: AwsRegion;
6
- bucketName: string;
7
- expectedBucketOwner: string;
8
- }) => Promise<Record<string, unknown>>;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deserializeInputProps = void 0;
4
- const io_1 = require("../functions/helpers/io");
5
- const constants_1 = require("./constants");
6
- const stream_to_string_1 = require("./stream-to-string");
7
- const deserializeInputProps = async ({ serialized, region, bucketName, expectedBucketOwner, }) => {
8
- if (serialized.type === 'payload') {
9
- return JSON.parse(serialized.payload);
10
- }
11
- try {
12
- const response = await (0, io_1.lambdaReadFile)({
13
- bucketName,
14
- expectedBucketOwner,
15
- key: (0, constants_1.inputPropsKey)(serialized.hash),
16
- region,
17
- });
18
- const body = await (0, stream_to_string_1.streamToString)(response);
19
- const payload = JSON.parse(body);
20
- return payload;
21
- }
22
- catch (err) {
23
- throw new Error(`Failed to parse input props that were serialized: ${err.stack}`);
24
- }
25
- };
26
- exports.deserializeInputProps = deserializeInputProps;
@@ -1,8 +0,0 @@
1
- import type { AwsRegion } from '../client';
2
- import type { SerializedInputProps } from './constants';
3
- export declare const serializeInputProps: ({ inputProps, region, type, userSpecifiedBucketName, }: {
4
- inputProps: Record<string, unknown>;
5
- region: AwsRegion;
6
- type: 'still' | 'video-or-audio';
7
- userSpecifiedBucketName: string | null;
8
- }) => Promise<SerializedInputProps>;
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.serializeInputProps = void 0;
4
- const get_or_create_bucket_1 = require("../api/get-or-create-bucket");
5
- const io_1 = require("../functions/helpers/io");
6
- const constants_1 = require("./constants");
7
- const random_hash_1 = require("./random-hash");
8
- const serializeInputProps = async ({ inputProps = {}, region, type, userSpecifiedBucketName, }) => {
9
- try {
10
- const payload = JSON.stringify(inputProps);
11
- const hash = (0, random_hash_1.randomHash)();
12
- const MAX_INLINE_PAYLOAD_SIZE = type === 'still' ? 5000000 : 200000;
13
- if (payload.length > MAX_INLINE_PAYLOAD_SIZE) {
14
- console.warn(`Warning: inputProps are over ${Math.round(MAX_INLINE_PAYLOAD_SIZE / 1000)}KB (${Math.ceil(payload.length / 1024)}KB) in size. Uploading them to S3 to circumvent AWS Lambda payload size.`);
15
- const bucketName = userSpecifiedBucketName !== null && userSpecifiedBucketName !== void 0 ? userSpecifiedBucketName : (await (0, get_or_create_bucket_1.getOrCreateBucket)({
16
- region,
17
- })).bucketName;
18
- await (0, io_1.lambdaWriteFile)({
19
- body: payload,
20
- bucketName,
21
- region,
22
- customCredentials: null,
23
- downloadBehavior: null,
24
- expectedBucketOwner: null,
25
- key: (0, constants_1.inputPropsKey)(hash),
26
- privacy: 'public',
27
- });
28
- return {
29
- type: 'bucket-url',
30
- hash,
31
- };
32
- }
33
- return {
34
- type: 'payload',
35
- payload,
36
- };
37
- }
38
- catch (err) {
39
- throw new Error('Error serializing inputProps. Check it has no circular references or reduce the size if the object is big.');
40
- }
41
- };
42
- exports.serializeInputProps = serializeInputProps;