@remotion/lambda 3.2.32 → 3.2.33

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.
@@ -1,4 +1,4 @@
1
- import minimist from 'minimist';
1
+ /// <reference types="minimist" />
2
2
  import type { AwsRegion } from '../pricing/aws-regions';
3
3
  import type { Privacy } from '../shared/constants';
4
4
  import type { LambdaArchitecture } from '../shared/validate-architecture';
@@ -27,6 +27,6 @@ declare type LambdaCommandLineOptions = {
27
27
  webhook: string | undefined;
28
28
  ['webhook-secret']: string | undefined;
29
29
  };
30
- export declare const parsedLambdaCli: LambdaCommandLineOptions & minimist.ParsedArgs;
30
+ export declare const parsedLambdaCli: LambdaCommandLineOptions & import("minimist").ParsedArgs;
31
31
  export declare const forceFlagProvided: boolean;
32
32
  export {};
package/dist/cli/args.js CHANGED
@@ -1,12 +1,8 @@
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
3
  exports.forceFlagProvided = exports.parsedLambdaCli = void 0;
7
4
  const cli_1 = require("@remotion/cli");
8
- const minimist_1 = __importDefault(require("minimist"));
9
- exports.parsedLambdaCli = (0, minimist_1.default)(process.argv.slice(2), {
5
+ exports.parsedLambdaCli = cli_1.CliInternals.minimist(process.argv.slice(2), {
10
6
  boolean: cli_1.CliInternals.BooleanFlags,
11
7
  });
12
8
  exports.forceFlagProvided = exports.parsedLambdaCli.f ||
@@ -6,6 +6,9 @@ export declare const planFrameRanges: ({ framesPerLambda, optimization, shouldUs
6
6
  frameRange: [number, number];
7
7
  everyNthFrame: number;
8
8
  }) => {
9
- chunks: [number, number][];
9
+ chunks: [
10
+ number,
11
+ number
12
+ ][];
10
13
  didUseOptimization: boolean;
11
14
  };
@@ -35,7 +35,7 @@ const deleteAllFilesInAFolderRecursively = (path) => {
35
35
  const deleteTmpDir = () => {
36
36
  exports.deletedFiles = [];
37
37
  exports.deletedFilesSize = 0;
38
- if (typeof jest === 'undefined') {
38
+ if (!process.env.VITEST) {
39
39
  deleteAllFilesInAFolderRecursively('/tmp');
40
40
  }
41
41
  };
@@ -1,9 +1,11 @@
1
1
  import type { AwsRegion } from '../../pricing/aws-regions';
2
2
  import type { LambdaCodec } from '../../shared/validate-lambda-codec';
3
- export declare const concatVideosS3: ({ bucket, expectedFiles, onProgress, numberOfFrames, renderId, region, codec, expectedBucketOwner, fps, numberOfGifLoops, }: {
3
+ import type { EnhancedErrorInfo } from './write-lambda-error';
4
+ export declare const concatVideosS3: ({ bucket, expectedFiles, onProgress, numberOfFrames, renderId, region, codec, expectedBucketOwner, fps, numberOfGifLoops, onErrors, }: {
4
5
  bucket: string;
5
6
  expectedFiles: number;
6
7
  onProgress: (frames: number, encodingStart: number) => void;
8
+ onErrors: (errors: EnhancedErrorInfo[]) => Promise<void>;
7
9
  numberOfFrames: number;
8
10
  renderId: string;
9
11
  region: AwsRegion;
@@ -28,6 +28,7 @@ const renderer_1 = require("@remotion/renderer");
28
28
  const fs_1 = __importStar(require("fs"));
29
29
  const path_1 = __importStar(require("path"));
30
30
  const constants_1 = require("../../shared/constants");
31
+ const inspect_errors_1 = require("./inspect-errors");
31
32
  const io_1 = require("./io");
32
33
  const timer_1 = require("./timer");
33
34
  const getChunkDownloadOutputLocation = ({ outdir, file, }) => {
@@ -50,11 +51,11 @@ const downloadS3File = async ({ bucket, key, outdir, region, expectedBucketOwner
50
51
  .on('close', () => resolve());
51
52
  });
52
53
  };
53
- const getAllFilesS3 = ({ bucket, expectedFiles, outdir, renderId, region, expectedBucketOwner, }) => {
54
+ const getAllFilesS3 = ({ bucket, expectedFiles, outdir, renderId, region, expectedBucketOwner, onErrors, }) => {
54
55
  const alreadyDownloading = {};
55
56
  const downloaded = {};
56
57
  const getFiles = async () => {
57
- const prefix = (0, constants_1.chunkKey)(renderId);
58
+ const prefix = (0, constants_1.rendersPrefix)(renderId);
58
59
  const lsTimer = (0, timer_1.timer)('Listing files');
59
60
  const contents = await (0, io_1.lambdaLs)({
60
61
  bucketName: bucket,
@@ -63,13 +64,16 @@ const getAllFilesS3 = ({ bucket, expectedFiles, outdir, renderId, region, expect
63
64
  expectedBucketOwner,
64
65
  });
65
66
  lsTimer.end();
66
- return contents
67
- .filter((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.chunkKey)(renderId)); })
68
- .map((_) => _.Key);
67
+ return {
68
+ filesInBucket: contents
69
+ .filter((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.chunkKey)(renderId)); })
70
+ .map((_) => _.Key),
71
+ errorContents: contents.filter((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.getErrorKeyPrefix)(renderId)); }),
72
+ };
69
73
  };
70
74
  return new Promise((resolve, reject) => {
71
75
  const loop = async () => {
72
- const filesInBucket = await getFiles();
76
+ const { filesInBucket, errorContents } = await getFiles();
73
77
  const checkFinish = () => {
74
78
  const areAllFilesDownloaded = Object.keys(downloaded).length === expectedFiles;
75
79
  console.log('Checking for finish... ', Object.keys(downloaded), expectedFiles + ' files expected');
@@ -79,6 +83,17 @@ const getAllFilesS3 = ({ bucket, expectedFiles, outdir, renderId, region, expect
79
83
  }
80
84
  };
81
85
  console.log('Found ', filesInBucket);
86
+ const errors = (await (0, inspect_errors_1.inspectErrors)({
87
+ bucket,
88
+ contents: errorContents,
89
+ expectedBucketOwner,
90
+ region,
91
+ renderId,
92
+ })).filter((e) => e.isFatal);
93
+ if (errors.length > 0) {
94
+ await onErrors(errors);
95
+ // Will die here
96
+ }
82
97
  filesInBucket.forEach(async (key) => {
83
98
  if (alreadyDownloading[key]) {
84
99
  return;
@@ -105,14 +120,14 @@ const getAllFilesS3 = ({ bucket, expectedFiles, outdir, renderId, region, expect
105
120
  const areAllFilesDownloading = Object.keys(alreadyDownloading).length === expectedFiles;
106
121
  if (!areAllFilesDownloading) {
107
122
  setTimeout(() => {
108
- loop();
123
+ loop().catch((err) => reject(err));
109
124
  }, 100);
110
125
  }
111
126
  };
112
- loop();
127
+ loop().catch((err) => reject(err));
113
128
  });
114
129
  };
115
- const concatVideosS3 = async ({ bucket, expectedFiles, onProgress, numberOfFrames, renderId, region, codec, expectedBucketOwner, fps, numberOfGifLoops, }) => {
130
+ const concatVideosS3 = async ({ bucket, expectedFiles, onProgress, numberOfFrames, renderId, region, codec, expectedBucketOwner, fps, numberOfGifLoops, onErrors, }) => {
116
131
  var _a;
117
132
  const outdir = (0, path_1.join)(renderer_1.RenderInternals.tmpDir(constants_1.CONCAT_FOLDER_TOKEN), 'bucket');
118
133
  if ((0, fs_1.existsSync)(outdir)) {
@@ -128,6 +143,7 @@ const concatVideosS3 = async ({ bucket, expectedFiles, onProgress, numberOfFrame
128
143
  renderId,
129
144
  region,
130
145
  expectedBucketOwner,
146
+ onErrors,
131
147
  });
132
148
  const outfile = (0, path_1.join)(renderer_1.RenderInternals.tmpDir(constants_1.REMOTION_CONCATED_TOKEN), 'concat.' + renderer_1.RenderInternals.getFileExtensionFromCodec(codec, 'final'));
133
149
  const combine = (0, timer_1.timer)('Combine videos');
@@ -10,7 +10,7 @@ const getCustomOutName = ({ renderMetadata, customCredentials, }) => {
10
10
  return renderMetadata.outName;
11
11
  }
12
12
  if (renderMetadata.outName.s3OutputProvider) {
13
- if (!customCredentials && renderMetadata.privacy !== 'public') {
13
+ if (!customCredentials && renderMetadata.privacy === 'private') {
14
14
  throw new TypeError(`The file was rendered with a custom S3 implementation and is not public, but no custom credentials were passed to downloadMedia().`);
15
15
  }
16
16
  return {
@@ -319,6 +319,32 @@ const innerLaunchHandler = async (params, options) => {
319
319
  });
320
320
  });
321
321
  };
322
+ const onErrors = async (errors) => {
323
+ var _a;
324
+ console.log('Found Errors', errors);
325
+ if (params.webhook) {
326
+ console.log('Sending webhook with errors');
327
+ await (0, invoke_webhook_1.invokeWebhook)({
328
+ url: params.webhook.url,
329
+ secret: (_a = params.webhook.secret) !== null && _a !== void 0 ? _a : null,
330
+ payload: {
331
+ type: 'error',
332
+ renderId: params.renderId,
333
+ expectedBucketOwner: options.expectedBucketOwner,
334
+ bucketName: params.bucketName,
335
+ errors: errors.slice(0, 5).map((e) => ({
336
+ message: e.message,
337
+ name: e.name,
338
+ stack: e.stack,
339
+ })),
340
+ },
341
+ });
342
+ }
343
+ else {
344
+ console.log('No webhook specified');
345
+ }
346
+ throw new Error('Stopping Lambda function because error occurred: ' + errors[0].stack);
347
+ };
322
348
  const fps = comp.fps / params.everyNthFrame;
323
349
  const { outfile, cleanupChunksProm, encodingStart } = await (0, concat_videos_1.concatVideosS3)({
324
350
  bucket: params.bucketName,
@@ -331,6 +357,7 @@ const innerLaunchHandler = async (params, options) => {
331
357
  expectedBucketOwner: options.expectedBucketOwner,
332
358
  fps,
333
359
  numberOfGifLoops: params.numberOfGifLoops,
360
+ onErrors,
334
361
  });
335
362
  if (!encodingStop) {
336
363
  encodingStop = Date.now();
@@ -197,6 +197,7 @@ const rendererHandler = async (params, options) => {
197
197
  }
198
198
  catch (err) {
199
199
  if (process.env.NODE_ENV === 'test') {
200
+ console.log({ err });
200
201
  throw err;
201
202
  }
202
203
  // If this error is encountered, we can just retry as it
package/dist/index.d.ts CHANGED
@@ -34,7 +34,7 @@ import type { RenderStillOnLambdaInput, RenderStillOnLambdaOutput } from './api/
34
34
  import { renderStillOnLambda } from './api/render-still-on-lambda';
35
35
  import { validateWebhookSignature } from './api/validate-webhook-signature';
36
36
  import type { LambdaLSInput, LambdaLsReturnType } from './functions/helpers/io';
37
- import type { LambdaErrorInfo } from './functions/helpers/write-lambda-error';
37
+ import type { EnhancedErrorInfo, LambdaErrorInfo } from './functions/helpers/write-lambda-error';
38
38
  import { LambdaInternals } from './internals';
39
39
  import type { AwsRegion } from './pricing/aws-regions';
40
40
  import type { CustomCredentials } from './shared/aws-clients';
@@ -42,4 +42,4 @@ import type { RenderProgress } from './shared/constants';
42
42
  import type { WebhookPayload } from './shared/invoke-webhook';
43
43
  import type { LambdaArchitecture } from './shared/validate-architecture';
44
44
  export { deleteSite, deployFunction, deploySite, downloadMedia, downloadVideo, getFunctions, getUserPolicy, getRolePolicy, getSites, getOrCreateBucket, getRenderProgress, renderVideoOnLambda, renderMediaOnLambda, simulatePermissions, deleteFunction, getFunctionInfo, estimatePrice, LambdaInternals, renderStillOnLambda, getRegions, getAwsClient, presignUrl, deleteRender, validateWebhookSignature, };
45
- export type { AwsRegion, RenderProgress, DeploySiteInput, DeploySiteOutput, LambdaLsReturnType, LambdaLSInput, DeleteSiteInput, DeleteSiteOutput, EstimatePriceInput, DeployFunctionInput, DeployFunctionOutput, DeleteFunctionInput, GetFunctionInfoInput, FunctionInfo, GetFunctionsInput, GetSitesInput, GetSitesOutput, DownloadMediaInput, DownloadMediaOutput, GetOrCreateBucketInput, GetOrCreateBucketOutput, GetRenderInput, RenderMediaOnLambdaInput, RenderMediaOnLambdaOutput, RenderStillOnLambdaInput, RenderStillOnLambdaOutput, SimulatePermissionsInput, SimulatePermissionsOutput, GetAwsClientInput, GetAwsClientOutput, LambdaArchitecture, CustomCredentials, WebhookPayload, LambdaErrorInfo, };
45
+ export type { AwsRegion, RenderProgress, DeploySiteInput, DeploySiteOutput, LambdaLsReturnType, LambdaLSInput, DeleteSiteInput, DeleteSiteOutput, EstimatePriceInput, DeployFunctionInput, DeployFunctionOutput, DeleteFunctionInput, GetFunctionInfoInput, FunctionInfo, GetFunctionsInput, GetSitesInput, GetSitesOutput, DownloadMediaInput, DownloadMediaOutput, GetOrCreateBucketInput, GetOrCreateBucketOutput, GetRenderInput, RenderMediaOnLambdaInput, RenderMediaOnLambdaOutput, RenderStillOnLambdaInput, RenderStillOnLambdaOutput, SimulatePermissionsInput, SimulatePermissionsOutput, GetAwsClientInput, GetAwsClientOutput, LambdaArchitecture, CustomCredentials, WebhookPayload, LambdaErrorInfo, EnhancedErrorInfo, };
package/package.json CHANGED
@@ -1,17 +1,16 @@
1
1
  {
2
2
  "name": "@remotion/lambda",
3
- "version": "3.2.32",
3
+ "version": "3.2.33",
4
4
  "description": "Distributed renderer for Remotion based on AWS Lambda",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,
7
7
  "bin": {
8
8
  "remotion-lambda": "remotion-lambda-cli.js"
9
9
  },
10
- "module": "true",
11
10
  "scripts": {
12
- "testintegration": "jest src/test/integration --runInBand --forceExit",
11
+ "testintegration": "vitest src/test/integration --run",
13
12
  "lint": "eslint src --ext ts,tsx",
14
- "test": "jest src/test/unit",
13
+ "test": "vitest src/test/unit --run",
15
14
  "watch": "tsc -w",
16
15
  "build": "tsc -d && pnpm run buildlambda",
17
16
  "buildlambda": "ts-node src/admin/bundle-lambda.ts",
@@ -32,12 +31,12 @@
32
31
  "@aws-sdk/client-service-quotas": "3.58.0",
33
32
  "@aws-sdk/lib-storage": "3.58.0",
34
33
  "@aws-sdk/s3-request-presigner": "3.58.0",
35
- "@remotion/bundler": "3.2.32",
36
- "@remotion/cli": "3.2.32",
37
- "@remotion/renderer": "3.2.32",
34
+ "@remotion/bundler": "3.2.33",
35
+ "@remotion/cli": "3.2.33",
36
+ "@remotion/renderer": "3.2.33",
38
37
  "aws-policies": "^1.0.1",
39
38
  "mime-types": "2.1.34",
40
- "remotion": "3.2.32"
39
+ "remotion": "3.2.33"
41
40
  },
42
41
  "peerDependencies": {
43
42
  "react": ">=16.8.0",
@@ -45,22 +44,20 @@
45
44
  },
46
45
  "devDependencies": {
47
46
  "@jonny/eslint-config": "3.0.266",
48
- "@types/jest": "^27.0.2",
49
47
  "@types/mime-types": "2.1.1",
50
48
  "@types/minimist": "1.2.2",
51
49
  "@types/node": "^14.14.14",
52
50
  "@types/prompt": "^1.1.0",
53
51
  "eslint": "8.13.0",
54
- "jest": "^27.2.4",
55
52
  "prettier": "^2.4.1",
56
53
  "prettier-plugin-organize-imports": "^2.3.4",
57
- "ts-jest": "^27.0.5",
58
54
  "ts-node": "^10.8.0",
59
55
  "typescript": "^4.7.0",
56
+ "vitest": "^0.24.3",
60
57
  "zip-lib": "^0.7.2"
61
58
  },
62
59
  "publishConfig": {
63
60
  "access": "public"
64
61
  },
65
- "gitHead": "4f7ab3637405d140041f898f95f78c99943d1b40"
62
+ "gitHead": "3c864e5ab73870674d028a1199005ddbabaede12"
66
63
  }
Binary file