@remotion/lambda 4.0.17 → 4.0.19

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/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: "info" | "error" | "verbose" | "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: "info" | "error" | "verbose" | "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: "info" | "error" | "verbose" | "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: "info" | "error" | "verbose" | "warn";
22
+ logLevel: "verbose" | "info" | "warn" | "error";
23
23
  } & {
24
24
  tag?: string | undefined;
25
25
  }, message?: any, ...optionalParams: any[]) => void;
@@ -9,7 +9,7 @@ export declare const getAllFilesS3: ({ bucket, expectedFiles, outdir, renderId,
9
9
  renderId: string;
10
10
  region: AwsRegion;
11
11
  expectedBucketOwner: string;
12
- onErrors: (errors: EnhancedErrorInfo[]) => Promise<void>;
12
+ onErrors: (errors: EnhancedErrorInfo[]) => void;
13
13
  }) => Promise<string[]>;
14
14
  export declare const concatVideosS3: ({ onProgress, numberOfFrames, codec, fps, numberOfGifLoops, files, outdir, audioCodec, }: {
15
15
  onProgress: (frames: number) => void;
@@ -96,7 +96,7 @@ const getAllFilesS3 = ({ bucket, expectedFiles, outdir, renderId, region, expect
96
96
  renderId,
97
97
  })).filter((e) => e.isFatal);
98
98
  if (errors.length > 0) {
99
- await onErrors(errors);
99
+ onErrors(errors);
100
100
  // Will die here
101
101
  }
102
102
  filesInBucket.forEach(async (key) => {
@@ -36,7 +36,6 @@ const compress_props_1 = require("../shared/compress-props");
36
36
  const constants_1 = require("../shared/constants");
37
37
  const docs_url_1 = require("../shared/docs-url");
38
38
  const invoke_webhook_1 = require("../shared/invoke-webhook");
39
- const make_s3_url_1 = require("../shared/make-s3-url");
40
39
  const validate_frames_per_lambda_1 = require("../shared/validate-frames-per-lambda");
41
40
  const validate_outname_1 = require("../shared/validate-outname");
42
41
  const validate_privacy_1 = require("../shared/validate-privacy");
@@ -89,51 +88,7 @@ const innerLaunchHandler = async (params, options) => {
89
88
  }
90
89
  const functionName = (_a = params.rendererFunctionName) !== null && _a !== void 0 ? _a : process.env.AWS_LAMBDA_FUNCTION_NAME;
91
90
  const startedDate = Date.now();
92
- let webhookInvoked = false;
93
- console.log(`Function has ${Math.max(options.getRemainingTimeInMillis() - 1000, 1000)} before it times out`);
94
91
  const verbose = renderer_1.RenderInternals.isEqualOrBelowLogLevel(params.logLevel, 'verbose');
95
- const webhookDueToTimeout = setTimeout(async () => {
96
- if (params.webhook && !webhookInvoked) {
97
- try {
98
- await (0, invoke_webhook_1.invokeWebhook)({
99
- url: params.webhook.url,
100
- secret: params.webhook.secret,
101
- payload: {
102
- type: 'timeout',
103
- renderId: params.renderId,
104
- expectedBucketOwner: options.expectedBucketOwner,
105
- bucketName: params.bucketName,
106
- },
107
- });
108
- webhookInvoked = true;
109
- }
110
- catch (err) {
111
- if (process.env.NODE_ENV === 'test') {
112
- throw err;
113
- }
114
- await (0, write_lambda_error_1.writeLambdaError)({
115
- bucketName: params.bucketName,
116
- errorInfo: {
117
- type: 'webhook',
118
- message: err.message,
119
- name: err.name,
120
- stack: err.stack,
121
- tmpDir: null,
122
- frame: 0,
123
- chunk: 0,
124
- isFatal: false,
125
- attempt: 1,
126
- willRetry: false,
127
- totalAttempts: 1,
128
- },
129
- renderId: params.renderId,
130
- expectedBucketOwner: options.expectedBucketOwner,
131
- });
132
- console.log('Failed to invoke webhook:');
133
- console.log(err);
134
- }
135
- }
136
- }, Math.max(options.getRemainingTimeInMillis() - 1000, 1000));
137
92
  const browserInstance = await (0, get_browser_instance_1.getBrowserInstance)(params.logLevel, false, params.chromiumOptions);
138
93
  const inputPropsPromise = (0, compress_props_1.decompressInputProps)({
139
94
  bucketName: params.bucketName,
@@ -245,7 +200,7 @@ const innerLaunchHandler = async (params, options) => {
245
200
  };
246
201
  return payload;
247
202
  });
248
- console.log('Render plan: ', chunks.map((c, i) => `Chunk ${i} (Frames ${c[0]} - ${c[1]})`).join(', '));
203
+ renderer_1.RenderInternals.Log.info('Render plan: ', chunks.map((c, i) => `Chunk ${i} (Frames ${c[0]} - ${c[1]})`).join(', '));
249
204
  const renderMetadata = {
250
205
  startedDate,
251
206
  videoConfig: comp,
@@ -258,7 +213,7 @@ const innerLaunchHandler = async (params, options) => {
258
213
  ].reduce((a, b) => a + b, 0),
259
214
  estimatedRenderLambdaInvokations: chunks.length,
260
215
  compositionId: comp.id,
261
- siteId: (0, make_s3_url_1.getServeUrlHash)(params.serveUrl),
216
+ siteId: params.serveUrl,
262
217
  codec: params.codec,
263
218
  type: 'video',
264
219
  imageFormat: params.imageFormat,
@@ -349,30 +304,8 @@ const innerLaunchHandler = async (params, options) => {
349
304
  });
350
305
  });
351
306
  };
352
- const onErrors = async (errors) => {
353
- var _a;
354
- console.log('Found Errors', errors);
355
- if (params.webhook) {
356
- console.log('Sending webhook with errors');
357
- await (0, invoke_webhook_1.invokeWebhook)({
358
- url: params.webhook.url,
359
- secret: (_a = params.webhook.secret) !== null && _a !== void 0 ? _a : null,
360
- payload: {
361
- type: 'error',
362
- renderId: params.renderId,
363
- expectedBucketOwner: options.expectedBucketOwner,
364
- bucketName: params.bucketName,
365
- errors: errors.slice(0, 5).map((e) => ({
366
- message: e.message,
367
- name: e.name,
368
- stack: e.stack,
369
- })),
370
- },
371
- });
372
- }
373
- else {
374
- console.log('No webhook specified');
375
- }
307
+ const onErrors = (errors) => {
308
+ renderer_1.RenderInternals.Log.error('Found Errors', errors);
376
309
  const firstError = errors[0];
377
310
  if (firstError.chunk !== null) {
378
311
  throw new Error(`Stopping Lambda function because error occurred while rendering chunk ${firstError.chunk}:\n${errors[0].stack
@@ -503,60 +436,104 @@ const innerLaunchHandler = async (params, options) => {
503
436
  customCredentials: null,
504
437
  });
505
438
  await Promise.all([cleanupChunksProm, node_fs_1.default.promises.rm(outfile)]);
506
- clearTimeout(webhookDueToTimeout);
507
- if (params.webhook && !webhookInvoked) {
508
- try {
509
- await (0, invoke_webhook_1.invokeWebhook)({
510
- url: params.webhook.url,
511
- secret: params.webhook.secret,
512
- payload: {
513
- type: 'success',
514
- renderId: params.renderId,
515
- expectedBucketOwner: options.expectedBucketOwner,
516
- bucketName: params.bucketName,
517
- outputUrl,
518
- lambdaErrors: postRenderData.errors,
519
- outputFile: postRenderData.outputFile,
520
- timeToFinish: postRenderData.timeToFinish,
521
- costs: postRenderData.cost,
522
- },
523
- });
524
- webhookInvoked = true;
525
- }
526
- catch (err) {
527
- if (process.env.NODE_ENV === 'test') {
528
- throw err;
529
- }
530
- await (0, write_lambda_error_1.writeLambdaError)({
531
- bucketName: params.bucketName,
532
- errorInfo: {
533
- type: 'webhook',
534
- message: err.message,
535
- name: err.name,
536
- stack: err.stack,
537
- tmpDir: null,
538
- frame: 0,
539
- chunk: 0,
540
- isFatal: false,
541
- attempt: 1,
542
- willRetry: false,
543
- totalAttempts: 1,
544
- },
545
- renderId: params.renderId,
546
- expectedBucketOwner: options.expectedBucketOwner,
547
- });
548
- console.log('Failed to invoke webhook:');
549
- console.log(err);
550
- }
551
- }
439
+ return postRenderData;
552
440
  };
553
441
  const launchHandler = async (params, options) => {
554
- var _a, _b;
555
442
  if (params.type !== constants_1.LambdaRoutines.launch) {
556
443
  throw new Error('Expected launch type');
557
444
  }
445
+ let webhookInvoked = false;
446
+ const webhookDueToTimeout = setTimeout(async () => {
447
+ if (params.webhook && !webhookInvoked) {
448
+ try {
449
+ await (0, invoke_webhook_1.invokeWebhook)({
450
+ url: params.webhook.url,
451
+ secret: params.webhook.secret,
452
+ payload: {
453
+ type: 'timeout',
454
+ renderId: params.renderId,
455
+ expectedBucketOwner: options.expectedBucketOwner,
456
+ bucketName: params.bucketName,
457
+ },
458
+ });
459
+ webhookInvoked = true;
460
+ }
461
+ catch (err) {
462
+ if (process.env.NODE_ENV === 'test') {
463
+ throw err;
464
+ }
465
+ await (0, write_lambda_error_1.writeLambdaError)({
466
+ bucketName: params.bucketName,
467
+ errorInfo: {
468
+ type: 'webhook',
469
+ message: err.message,
470
+ name: err.name,
471
+ stack: err.stack,
472
+ tmpDir: null,
473
+ frame: 0,
474
+ chunk: 0,
475
+ isFatal: false,
476
+ attempt: 1,
477
+ willRetry: false,
478
+ totalAttempts: 1,
479
+ },
480
+ renderId: params.renderId,
481
+ expectedBucketOwner: options.expectedBucketOwner,
482
+ });
483
+ renderer_1.RenderInternals.Log.error('Failed to invoke webhook:');
484
+ renderer_1.RenderInternals.Log.error(err);
485
+ }
486
+ }
487
+ }, Math.max(options.getRemainingTimeInMillis() - 1000, 1000));
488
+ renderer_1.RenderInternals.Log.info(`Function has ${Math.max(options.getRemainingTimeInMillis() - 1000, 1000)} before it times out`);
558
489
  try {
559
- await innerLaunchHandler(params, options);
490
+ const postRenderData = await innerLaunchHandler(params, options);
491
+ clearTimeout(webhookDueToTimeout);
492
+ if (params.webhook && !webhookInvoked) {
493
+ try {
494
+ await (0, invoke_webhook_1.invokeWebhook)({
495
+ url: params.webhook.url,
496
+ secret: params.webhook.secret,
497
+ payload: {
498
+ type: 'success',
499
+ renderId: params.renderId,
500
+ expectedBucketOwner: options.expectedBucketOwner,
501
+ bucketName: params.bucketName,
502
+ outputUrl: postRenderData.outputFile,
503
+ lambdaErrors: postRenderData.errors,
504
+ outputFile: postRenderData.outputFile,
505
+ timeToFinish: postRenderData.timeToFinish,
506
+ costs: postRenderData.cost,
507
+ },
508
+ });
509
+ webhookInvoked = true;
510
+ }
511
+ catch (err) {
512
+ if (process.env.NODE_ENV === 'test') {
513
+ throw err;
514
+ }
515
+ await (0, write_lambda_error_1.writeLambdaError)({
516
+ bucketName: params.bucketName,
517
+ errorInfo: {
518
+ type: 'webhook',
519
+ message: err.message,
520
+ name: err.name,
521
+ stack: err.stack,
522
+ tmpDir: null,
523
+ frame: 0,
524
+ chunk: 0,
525
+ isFatal: false,
526
+ attempt: 1,
527
+ willRetry: false,
528
+ totalAttempts: 1,
529
+ },
530
+ renderId: params.renderId,
531
+ expectedBucketOwner: options.expectedBucketOwner,
532
+ });
533
+ renderer_1.RenderInternals.Log.error('Failed to invoke webhook:');
534
+ renderer_1.RenderInternals.Log.error(err);
535
+ }
536
+ }
560
537
  return {
561
538
  type: 'success',
562
539
  };
@@ -565,7 +542,7 @@ const launchHandler = async (params, options) => {
565
542
  if (process.env.NODE_ENV === 'test') {
566
543
  throw err;
567
544
  }
568
- console.log('Error occurred', err);
545
+ renderer_1.RenderInternals.Log.error('Error occurred', err);
569
546
  await (0, write_lambda_error_1.writeLambdaError)({
570
547
  bucketName: params.bucketName,
571
548
  errorInfo: {
@@ -584,11 +561,12 @@ const launchHandler = async (params, options) => {
584
561
  expectedBucketOwner: options.expectedBucketOwner,
585
562
  renderId: params.renderId,
586
563
  });
587
- if ((_a = params.webhook) === null || _a === void 0 ? void 0 : _a.url) {
564
+ clearTimeout(webhookDueToTimeout);
565
+ if (params.webhook && !webhookInvoked) {
588
566
  try {
589
567
  await (0, invoke_webhook_1.invokeWebhook)({
590
568
  url: params.webhook.url,
591
- secret: (_b = params.webhook.secret) !== null && _b !== void 0 ? _b : null,
569
+ secret: params.webhook.secret,
592
570
  payload: {
593
571
  type: 'error',
594
572
  renderId: params.renderId,
@@ -601,6 +579,7 @@ const launchHandler = async (params, options) => {
601
579
  })),
602
580
  },
603
581
  });
582
+ webhookInvoked = true;
604
583
  }
605
584
  catch (error) {
606
585
  if (process.env.NODE_ENV === 'test') {
@@ -624,8 +603,8 @@ const launchHandler = async (params, options) => {
624
603
  renderId: params.renderId,
625
604
  expectedBucketOwner: options.expectedBucketOwner,
626
605
  });
627
- console.log('Failed to invoke webhook:');
628
- console.log(error);
606
+ renderer_1.RenderInternals.Log.error('Failed to invoke webhook:');
607
+ renderer_1.RenderInternals.Log.error(error);
629
608
  }
630
609
  }
631
610
  throw err;
@@ -17,7 +17,6 @@ const compress_props_1 = require("../shared/compress-props");
17
17
  const constants_1 = require("../shared/constants");
18
18
  const convert_to_serve_url_1 = require("../shared/convert-to-serve-url");
19
19
  const is_flaky_error_1 = require("../shared/is-flaky-error");
20
- const make_s3_url_1 = require("../shared/make-s3-url");
21
20
  const validate_download_behavior_1 = require("../shared/validate-download-behavior");
22
21
  const validate_outname_1 = require("../shared/validate-outname");
23
22
  const validate_privacy_1 = require("../shared/validate-privacy");
@@ -96,7 +95,7 @@ const innerStillHandler = async ({ params: lambdaParams, expectedBucketOwner, re
96
95
  compositionId: lambdaParams.composition,
97
96
  estimatedTotalLambdaInvokations: 1,
98
97
  estimatedRenderLambdaInvokations: 1,
99
- siteId: (0, make_s3_url_1.getServeUrlHash)(serveUrl),
98
+ siteId: serveUrl,
100
99
  totalChunks: 1,
101
100
  type: 'still',
102
101
  imageFormat: lambdaParams.imageFormat,
@@ -4,4 +4,3 @@ export declare const makeS3ServeUrl: ({ bucketName, subFolder, region, }: {
4
4
  subFolder: string;
5
5
  region: AwsRegion;
6
6
  }) => string;
7
- export declare const getServeUrlHash: (url: string) => string;
@@ -1,21 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getServeUrlHash = exports.makeS3ServeUrl = void 0;
7
- const node_crypto_1 = __importDefault(require("node:crypto"));
3
+ exports.makeS3ServeUrl = void 0;
8
4
  const makeS3ServeUrl = ({ bucketName, subFolder, region, }) => {
9
5
  return `https://${bucketName}.s3.${region}.amazonaws.com/${subFolder}/index.html`;
10
6
  };
11
7
  exports.makeS3ServeUrl = makeS3ServeUrl;
12
- const hashCache = {};
13
- const getServeUrlHash = (url) => {
14
- if (hashCache[url]) {
15
- return hashCache[url];
16
- }
17
- const hash = node_crypto_1.default.createHash('md5').update(url).digest('hex');
18
- hashCache[url] = hash;
19
- return hash;
20
- };
21
- exports.getServeUrlHash = getServeUrlHash;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/lambda",
3
- "version": "4.0.17",
3
+ "version": "4.0.19",
4
4
  "description": "Distributed renderer for Remotion based on AWS Lambda",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,
@@ -13,7 +13,7 @@
13
13
  "url": "https://github.com/JonnyBurger/remotion"
14
14
  },
15
15
  "dependencies": {
16
- "@aws-sdk/abort-controller": "3.374.0",
16
+ "@smithy/abort-controller": "2.0.1",
17
17
  "@aws-sdk/client-cloudwatch-logs": "3.382.0",
18
18
  "@aws-sdk/client-iam": "3.382.0",
19
19
  "@aws-sdk/client-lambda": "3.382.0",
@@ -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.17",
30
- "remotion": "4.0.17",
31
- "@remotion/renderer": "4.0.17",
32
- "@remotion/cli": "4.0.17"
29
+ "@remotion/bundler": "4.0.19",
30
+ "@remotion/cli": "4.0.19",
31
+ "@remotion/renderer": "4.0.19",
32
+ "remotion": "4.0.19"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@jonny/eslint-config": "3.0.266",
@@ -41,14 +41,13 @@
41
41
  "prettier": "^2.4.1",
42
42
  "prettier-plugin-organize-imports": "^3.2.2",
43
43
  "ts-node": "^10.8.0",
44
- "typescript": "4.9.5",
45
44
  "vitest": "0.31.1",
46
45
  "zip-lib": "^0.7.2",
47
- "@remotion/bundler": "4.0.17",
48
- "@remotion/compositor-linux-arm64-gnu": "4.0.17"
46
+ "@remotion/bundler": "4.0.19",
47
+ "@remotion/compositor-linux-arm64-gnu": "4.0.19"
49
48
  },
50
49
  "peerDependencies": {
51
- "@remotion/bundler": "4.0.17"
50
+ "@remotion/bundler": "4.0.19"
52
51
  },
53
52
  "publishConfig": {
54
53
  "access": "public"
Binary file
@@ -1 +0,0 @@
1
- export declare const isFlakyError: (err: Error) => boolean;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isFlakyError = void 0;
4
- const isFlakyError = (err) => {
5
- const { message } = err;
6
- return (message.includes('FATAL:zygote_communication_linux.cc') ||
7
- message.includes('error while loading shared libraries: libnss3.so') ||
8
- message.includes('but the server sent no data') ||
9
- message.includes('Compositor panicked') ||
10
- (message.includes('Compositor exited') && !message.includes('SIGSEGV')) ||
11
- message.includes('Timed out while setting up the headless browser'));
12
- };
13
- exports.isFlakyError = isFlakyError;