@remotion/lambda 4.0.256 → 4.0.257

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 (126) hide show
  1. package/package.json +12 -12
  2. package/remotionlambda-arm64.zip +0 -0
  3. package/dist/api/__mocks__/clean-items.d.ts +0 -2
  4. package/dist/api/__mocks__/clean-items.js +0 -24
  5. package/dist/api/__mocks__/create-function.d.ts +0 -2
  6. package/dist/api/__mocks__/create-function.js +0 -21
  7. package/dist/api/__mocks__/delete-function.d.ts +0 -2
  8. package/dist/api/__mocks__/delete-function.js +0 -9
  9. package/dist/api/__mocks__/get-functions.d.ts +0 -2
  10. package/dist/api/__mocks__/get-functions.js +0 -9
  11. package/dist/api/__mocks__/upload-dir.d.ts +0 -3
  12. package/dist/api/__mocks__/upload-dir.js +0 -47
  13. package/dist/api/mock-functions.d.ts +0 -18
  14. package/dist/api/mock-functions.js +0 -36
  15. package/dist/cli/helpers/__mocks__/quit.d.ts +0 -1
  16. package/dist/cli/helpers/__mocks__/quit.js +0 -7
  17. package/dist/functions/chunk-optimization/plan-frame-ranges.d.ts +0 -7
  18. package/dist/functions/chunk-optimization/plan-frame-ranges.js +0 -17
  19. package/dist/functions/chunk-optimization/types.d.ts +0 -8
  20. package/dist/functions/chunk-optimization/types.js +0 -2
  21. package/dist/functions/helpers/__mocks__/get-browser-instance.d.ts +0 -3
  22. package/dist/functions/helpers/__mocks__/get-browser-instance.js +0 -12
  23. package/dist/functions/helpers/__mocks__/leak-detection.d.ts +0 -4
  24. package/dist/functions/helpers/__mocks__/leak-detection.js +0 -9
  25. package/dist/functions/helpers/__mocks__/timer.d.ts +0 -2
  26. package/dist/functions/helpers/__mocks__/timer.js +0 -10
  27. package/dist/functions/helpers/best-frames-per-lambda-param.d.ts +0 -1
  28. package/dist/functions/helpers/best-frames-per-lambda-param.js +0 -17
  29. package/dist/functions/helpers/calculate-chunk-times.d.ts +0 -5
  30. package/dist/functions/helpers/calculate-chunk-times.js +0 -29
  31. package/dist/functions/helpers/calculate-price-from-bucket.d.ts +0 -15
  32. package/dist/functions/helpers/calculate-price-from-bucket.js +0 -30
  33. package/dist/functions/helpers/can-concat-seamlessly.d.ts +0 -3
  34. package/dist/functions/helpers/can-concat-seamlessly.js +0 -17
  35. package/dist/functions/helpers/cleanup-props.d.ts +0 -8
  36. package/dist/functions/helpers/cleanup-props.js +0 -23
  37. package/dist/functions/helpers/concat-videos.d.ts +0 -23
  38. package/dist/functions/helpers/concat-videos.js +0 -54
  39. package/dist/functions/helpers/create-post-render-data.d.ts +0 -17
  40. package/dist/functions/helpers/create-post-render-data.js +0 -67
  41. package/dist/functions/helpers/find-output-file-in-bucket.d.ts +0 -14
  42. package/dist/functions/helpers/find-output-file-in-bucket.js +0 -38
  43. package/dist/functions/helpers/format-costs-info.d.ts +0 -2
  44. package/dist/functions/helpers/format-costs-info.js +0 -23
  45. package/dist/functions/helpers/get-overall-progress-s3.d.ts +0 -10
  46. package/dist/functions/helpers/get-overall-progress-s3.js +0 -24
  47. package/dist/functions/helpers/get-overall-progress.d.ts +0 -9
  48. package/dist/functions/helpers/get-overall-progress.js +0 -23
  49. package/dist/functions/helpers/get-progress.d.ts +0 -15
  50. package/dist/functions/helpers/get-progress.js +0 -254
  51. package/dist/functions/helpers/get-retry-stats.d.ts +0 -5
  52. package/dist/functions/helpers/get-retry-stats.js +0 -2
  53. package/dist/functions/helpers/inspect-errors.d.ts +0 -4
  54. package/dist/functions/helpers/inspect-errors.js +0 -39
  55. package/dist/functions/helpers/is-warm.d.ts +0 -2
  56. package/dist/functions/helpers/is-warm.js +0 -10
  57. package/dist/functions/helpers/leak-detection.d.ts +0 -4
  58. package/dist/functions/helpers/leak-detection.js +0 -40
  59. package/dist/functions/helpers/make-timeout-error.d.ts +0 -10
  60. package/dist/functions/helpers/make-timeout-error.js +0 -31
  61. package/dist/functions/helpers/make-timeout-message.d.ts +0 -10
  62. package/dist/functions/helpers/make-timeout-message.js +0 -75
  63. package/dist/functions/helpers/merge-chunks.d.ts +0 -36
  64. package/dist/functions/helpers/merge-chunks.js +0 -84
  65. package/dist/functions/helpers/min-max.d.ts +0 -2
  66. package/dist/functions/helpers/min-max.js +0 -33
  67. package/dist/functions/helpers/on-downloads-logger.d.ts +0 -2
  68. package/dist/functions/helpers/on-downloads-logger.js +0 -29
  69. package/dist/functions/helpers/overall-render-progress.d.ts +0 -59
  70. package/dist/functions/helpers/overall-render-progress.js +0 -180
  71. package/dist/functions/helpers/print-concurrency-curve.d.ts +0 -1
  72. package/dist/functions/helpers/print-concurrency-curve.js +0 -8
  73. package/dist/functions/helpers/print-logging-helper.d.ts +0 -4
  74. package/dist/functions/helpers/print-logging-helper.js +0 -12
  75. package/dist/functions/helpers/render-has-audio-video.d.ts +0 -6
  76. package/dist/functions/helpers/render-has-audio-video.js +0 -21
  77. package/dist/functions/helpers/request-context.d.ts +0 -5
  78. package/dist/functions/helpers/request-context.js +0 -2
  79. package/dist/functions/helpers/stream-renderer.d.ts +0 -17
  80. package/dist/functions/helpers/stream-renderer.js +0 -148
  81. package/dist/functions/launch.d.ts +0 -10
  82. package/dist/functions/launch.js +0 -595
  83. package/dist/functions/progress.d.ts +0 -11
  84. package/dist/functions/progress.js +0 -51
  85. package/dist/functions/renderer.d.ts +0 -17
  86. package/dist/functions/renderer.js +0 -341
  87. package/dist/functions/start.d.ts +0 -13
  88. package/dist/functions/start.js +0 -112
  89. package/dist/functions/still.d.ts +0 -19
  90. package/dist/functions/still.js +0 -329
  91. package/dist/shared/__mocks__/aws-clients.d.ts +0 -2
  92. package/dist/shared/__mocks__/aws-clients.js +0 -62
  93. package/dist/shared/__mocks__/bundle-site.d.ts +0 -2
  94. package/dist/shared/__mocks__/bundle-site.js +0 -32
  95. package/dist/shared/__mocks__/check-credentials.d.ts +0 -1
  96. package/dist/shared/__mocks__/check-credentials.js +0 -5
  97. package/dist/shared/__mocks__/get-account-id.d.ts +0 -2
  98. package/dist/shared/__mocks__/get-account-id.js +0 -11
  99. package/dist/shared/__mocks__/read-dir.d.ts +0 -2
  100. package/dist/shared/__mocks__/read-dir.js +0 -13
  101. package/dist/shared/call-lambda.d.ts +0 -16
  102. package/dist/shared/call-lambda.js +0 -149
  103. package/dist/shared/cleanup-serialized-input-props.d.ts +0 -14
  104. package/dist/shared/cleanup-serialized-input-props.js +0 -34
  105. package/dist/shared/docs-url.d.ts +0 -1
  106. package/dist/shared/docs-url.js +0 -4
  107. package/dist/shared/get-most-expensive-chunks.d.ts +0 -8
  108. package/dist/shared/get-most-expensive-chunks.js +0 -28
  109. package/dist/shared/invoke-webhook.d.ts +0 -48
  110. package/dist/shared/invoke-webhook.js +0 -140
  111. package/dist/shared/parse-lambda-timings-key.d.ts +0 -5
  112. package/dist/shared/parse-lambda-timings-key.js +0 -2
  113. package/dist/shared/return-values.d.ts +0 -16
  114. package/dist/shared/return-values.js +0 -2
  115. package/dist/shared/stackback.d.ts +0 -6
  116. package/dist/shared/stackback.js +0 -59
  117. package/dist/shared/validate-download-behavior.d.ts +0 -1
  118. package/dist/shared/validate-download-behavior.js +0 -21
  119. package/dist/shared/validate-frames-per-lambda.d.ts +0 -4
  120. package/dist/shared/validate-frames-per-lambda.js +0 -29
  121. package/dist/shared/validate-privacy.d.ts +0 -2
  122. package/dist/shared/validate-privacy.js +0 -14
  123. package/dist/shared/validate.d.ts +0 -4
  124. package/dist/shared/validate.js +0 -8
  125. package/dist/shared/why-is-node-running.d.ts +0 -15
  126. package/dist/shared/why-is-node-running.js +0 -88
@@ -1,329 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.stillHandler = void 0;
7
- const renderer_1 = require("@remotion/renderer");
8
- const serverless_1 = require("@remotion/serverless");
9
- const client_1 = require("@remotion/serverless/client");
10
- const node_fs_1 = __importDefault(require("node:fs"));
11
- const node_path_1 = __importDefault(require("node:path"));
12
- const no_react_1 = require("remotion/no-react");
13
- const version_1 = require("remotion/version");
14
- const estimate_price_1 = require("../api/estimate-price");
15
- const defaults_1 = require("../defaults");
16
- const cleanup_serialized_input_props_1 = require("../shared/cleanup-serialized-input-props");
17
- const is_flaky_error_1 = require("../shared/is-flaky-error");
18
- const validate_download_behavior_1 = require("../shared/validate-download-behavior");
19
- const validate_privacy_1 = require("../shared/validate-privacy");
20
- const format_costs_info_1 = require("./helpers/format-costs-info");
21
- const get_output_url_from_metadata_1 = require("./helpers/get-output-url-from-metadata");
22
- const on_downloads_logger_1 = require("./helpers/on-downloads-logger");
23
- const overall_render_progress_1 = require("./helpers/overall-render-progress");
24
- const innerStillHandler = async ({ params: lambdaParams, expectedBucketOwner, renderId, onStream, timeoutInMilliseconds, providerSpecifics, }, cleanup) => {
25
- var _a, _b, _c, _d, _e, _f, _g;
26
- if (lambdaParams.type !== client_1.ServerlessRoutines.still) {
27
- throw new TypeError('Expected still type');
28
- }
29
- if (lambdaParams.version !== version_1.VERSION) {
30
- if (!lambdaParams.version) {
31
- throw new Error(`Version mismatch: When calling renderStillOnLambda(), 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 renderStillOnLambda(). See: https://www.remotion.dev/docs/lambda/upgrading`);
32
- }
33
- throw new Error(`Version mismatch: When calling renderStillOnLambda(), 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 renderStillOnLambda(). See: https://www.remotion.dev/docs/lambda/upgrading`);
34
- }
35
- (0, validate_download_behavior_1.validateDownloadBehavior)(lambdaParams.downloadBehavior);
36
- (0, validate_privacy_1.validatePrivacy)(lambdaParams.privacy, true);
37
- (0, serverless_1.validateOutname)({
38
- outName: lambdaParams.outName,
39
- codec: null,
40
- audioCodecSetting: null,
41
- separateAudioTo: null,
42
- });
43
- const start = Date.now();
44
- const browserInstancePromise = (0, serverless_1.getBrowserInstance)({
45
- logLevel: lambdaParams.logLevel,
46
- indent: false,
47
- chromiumOptions: lambdaParams.chromiumOptions,
48
- providerSpecifics,
49
- });
50
- const bucketNamePromise = (_a = lambdaParams.bucketName) !== null && _a !== void 0 ? _a : (0, client_1.internalGetOrCreateBucket)({
51
- region: providerSpecifics.getCurrentRegionInFunction(),
52
- enableFolderExpiry: null,
53
- customCredentials: null,
54
- providerSpecifics,
55
- forcePathStyle: lambdaParams.forcePathStyle,
56
- }).then((b) => b.bucketName);
57
- const outputDir = renderer_1.RenderInternals.tmpDir('remotion-render-');
58
- const outputPath = node_path_1.default.join(outputDir, 'output');
59
- const region = providerSpecifics.getCurrentRegionInFunction();
60
- const bucketName = await bucketNamePromise;
61
- const serializedInputPropsWithCustomSchema = await (0, client_1.decompressInputProps)({
62
- bucketName,
63
- expectedBucketOwner,
64
- region,
65
- serialized: lambdaParams.inputProps,
66
- propsType: 'input-props',
67
- providerSpecifics,
68
- forcePathStyle: lambdaParams.forcePathStyle,
69
- });
70
- const serveUrl = providerSpecifics.convertToServeUrl({
71
- urlOrId: lambdaParams.serveUrl,
72
- region,
73
- bucketName,
74
- });
75
- const { server, cleanupServer } = await renderer_1.RenderInternals.makeOrReuseServer(undefined, {
76
- concurrency: 1,
77
- indent: false,
78
- port: null,
79
- remotionRoot: process.cwd(),
80
- logLevel: lambdaParams.logLevel,
81
- webpackConfigOrServeUrl: serveUrl,
82
- offthreadVideoCacheSizeInBytes: lambdaParams.offthreadVideoCacheSizeInBytes,
83
- binariesDirectory: null,
84
- forceIPv4: false,
85
- }, {
86
- onDownload: () => undefined,
87
- });
88
- cleanup.push(() => cleanupServer(true));
89
- const browserInstance = await browserInstancePromise;
90
- const composition = await (0, serverless_1.validateComposition)({
91
- serveUrl,
92
- browserInstance: browserInstance.instance,
93
- composition: lambdaParams.composition,
94
- serializedInputPropsWithCustomSchema,
95
- envVariables: (_b = lambdaParams.envVariables) !== null && _b !== void 0 ? _b : {},
96
- chromiumOptions: lambdaParams.chromiumOptions,
97
- timeoutInMilliseconds: lambdaParams.timeoutInMilliseconds,
98
- port: null,
99
- forceHeight: lambdaParams.forceHeight,
100
- forceWidth: lambdaParams.forceWidth,
101
- logLevel: lambdaParams.logLevel,
102
- server,
103
- offthreadVideoCacheSizeInBytes: lambdaParams.offthreadVideoCacheSizeInBytes,
104
- onBrowserDownload: () => {
105
- throw new Error('Should not download a browser in Lambda');
106
- },
107
- onServeUrlVisited: () => undefined,
108
- providerSpecifics,
109
- });
110
- const renderMetadata = {
111
- startedDate: Date.now(),
112
- codec: null,
113
- compositionId: lambdaParams.composition,
114
- estimatedTotalLambdaInvokations: 1,
115
- estimatedRenderLambdaInvokations: 1,
116
- siteId: serveUrl,
117
- totalChunks: 1,
118
- type: 'still',
119
- imageFormat: lambdaParams.imageFormat,
120
- inputProps: lambdaParams.inputProps,
121
- lambdaVersion: version_1.VERSION,
122
- framesPerLambda: 1,
123
- memorySizeInMb: Number(process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE),
124
- region: providerSpecifics.getCurrentRegionInFunction(),
125
- renderId,
126
- outName: (_c = lambdaParams.outName) !== null && _c !== void 0 ? _c : undefined,
127
- privacy: lambdaParams.privacy,
128
- audioCodec: null,
129
- deleteAfter: lambdaParams.deleteAfter,
130
- numberOfGifLoops: null,
131
- downloadBehavior: lambdaParams.downloadBehavior,
132
- audioBitrate: null,
133
- metadata: null,
134
- functionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
135
- dimensions: {
136
- height: composition.height * ((_d = lambdaParams.scale) !== null && _d !== void 0 ? _d : 1),
137
- width: composition.width * ((_e = lambdaParams.scale) !== null && _e !== void 0 ? _e : 1),
138
- },
139
- };
140
- const still = (0, overall_render_progress_1.makeInitialOverallRenderProgress)(timeoutInMilliseconds);
141
- still.renderMetadata = renderMetadata;
142
- await providerSpecifics.writeFile({
143
- bucketName,
144
- key: (0, client_1.overallProgressKey)(renderId),
145
- body: JSON.stringify(still),
146
- region: providerSpecifics.getCurrentRegionInFunction(),
147
- privacy: 'private',
148
- expectedBucketOwner,
149
- downloadBehavior: null,
150
- customCredentials: null,
151
- forcePathStyle: lambdaParams.forcePathStyle,
152
- });
153
- const onBrowserDownload = () => {
154
- throw new Error('Should not download a browser in Lambda');
155
- };
156
- const receivedArtifact = [];
157
- const { key, renderBucketName, customCredentials } = (0, client_1.getExpectedOutName)(renderMetadata, bucketName, (0, serverless_1.getCredentialsFromOutName)(lambdaParams.outName));
158
- const onArtifact = (artifact) => {
159
- if (receivedArtifact.find((a) => a.filename === artifact.filename)) {
160
- return { alreadyExisted: true };
161
- }
162
- const storageKey = (0, client_1.artifactName)(renderMetadata.renderId, artifact.filename);
163
- receivedArtifact.push(providerSpecifics.makeArtifactWithDetails({
164
- storageKey,
165
- artifact,
166
- region,
167
- renderBucketName,
168
- }));
169
- const startTime = Date.now();
170
- renderer_1.RenderInternals.Log.info({ indent: false, logLevel: lambdaParams.logLevel }, 'Writing artifact ' + artifact.filename + ' to S3');
171
- providerSpecifics
172
- .writeFile({
173
- bucketName: renderBucketName,
174
- key: storageKey,
175
- body: artifact.content,
176
- region,
177
- privacy: lambdaParams.privacy,
178
- expectedBucketOwner,
179
- downloadBehavior: lambdaParams.downloadBehavior,
180
- customCredentials,
181
- forcePathStyle: lambdaParams.forcePathStyle,
182
- })
183
- .then(() => {
184
- renderer_1.RenderInternals.Log.info({ indent: false, logLevel: lambdaParams.logLevel }, `Wrote artifact to S3 in ${Date.now() - startTime}ms`);
185
- })
186
- .catch((err) => {
187
- renderer_1.RenderInternals.Log.error({ indent: false, logLevel: lambdaParams.logLevel }, 'Failed to write artifact to S3', err);
188
- });
189
- return { alreadyExisted: false };
190
- };
191
- await renderer_1.RenderInternals.internalRenderStill({
192
- composition,
193
- output: outputPath,
194
- serveUrl,
195
- envVariables: (_f = lambdaParams.envVariables) !== null && _f !== void 0 ? _f : {},
196
- frame: renderer_1.RenderInternals.convertToPositiveFrameIndex({
197
- frame: lambdaParams.frame,
198
- durationInFrames: composition.durationInFrames,
199
- }),
200
- imageFormat: lambdaParams.imageFormat,
201
- serializedInputPropsWithCustomSchema,
202
- overwrite: false,
203
- puppeteerInstance: browserInstance.instance,
204
- jpegQuality: (_g = lambdaParams.jpegQuality) !== null && _g !== void 0 ? _g : renderer_1.RenderInternals.DEFAULT_JPEG_QUALITY,
205
- chromiumOptions: lambdaParams.chromiumOptions,
206
- scale: lambdaParams.scale,
207
- timeoutInMilliseconds: lambdaParams.timeoutInMilliseconds,
208
- browserExecutable: providerSpecifics.getChromiumPath(),
209
- cancelSignal: null,
210
- indent: false,
211
- onBrowserLog: null,
212
- onDownload: (0, on_downloads_logger_1.onDownloadsHelper)(lambdaParams.logLevel),
213
- port: null,
214
- server,
215
- logLevel: lambdaParams.logLevel,
216
- serializedResolvedPropsWithCustomSchema: no_react_1.NoReactInternals.serializeJSONWithDate({
217
- indent: undefined,
218
- staticBase: null,
219
- data: composition.props,
220
- }).serializedString,
221
- offthreadVideoCacheSizeInBytes: lambdaParams.offthreadVideoCacheSizeInBytes,
222
- binariesDirectory: null,
223
- onBrowserDownload,
224
- onArtifact,
225
- });
226
- const { size } = await node_fs_1.default.promises.stat(outputPath);
227
- await providerSpecifics.writeFile({
228
- bucketName: renderBucketName,
229
- key,
230
- privacy: lambdaParams.privacy,
231
- body: node_fs_1.default.createReadStream(outputPath),
232
- expectedBucketOwner,
233
- region: providerSpecifics.getCurrentRegionInFunction(),
234
- downloadBehavior: lambdaParams.downloadBehavior,
235
- customCredentials,
236
- forcePathStyle: lambdaParams.forcePathStyle,
237
- });
238
- await Promise.all([
239
- node_fs_1.default.promises.rm(outputPath, { recursive: true }),
240
- (0, cleanup_serialized_input_props_1.cleanupSerializedInputProps)({
241
- region: providerSpecifics.getCurrentRegionInFunction(),
242
- serialized: lambdaParams.inputProps,
243
- providerSpecifics,
244
- forcePathStyle: lambdaParams.forcePathStyle,
245
- }),
246
- server.closeServer(true),
247
- ]);
248
- const estimatedPrice = (0, estimate_price_1.estimatePrice)({
249
- durationInMilliseconds: Date.now() - start + 100,
250
- memorySizeInMb: Number(process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE),
251
- region: providerSpecifics.getCurrentRegionInFunction(),
252
- lambdasInvoked: 1,
253
- // We cannot determine the ephemeral storage size, so we
254
- // overestimate the price, but will only have a miniscule effect (~0.2%)
255
- diskSizeInMb: defaults_1.MAX_EPHEMERAL_STORAGE_IN_MB,
256
- });
257
- const { key: outKey, url } = (0, get_output_url_from_metadata_1.getOutputUrlFromMetadata)(renderMetadata, bucketName, customCredentials, providerSpecifics.getCurrentRegionInFunction());
258
- const payload = {
259
- type: 'success',
260
- output: url,
261
- size,
262
- sizeInBytes: size,
263
- bucketName,
264
- estimatedPrice: (0, format_costs_info_1.formatCostsInfo)(estimatedPrice),
265
- renderId,
266
- outKey,
267
- receivedArtifacts: receivedArtifact,
268
- };
269
- onStream({
270
- type: 'still-rendered',
271
- payload,
272
- });
273
- await server.closeServer(true);
274
- };
275
- const stillHandler = async (options) => {
276
- const { params } = options;
277
- const cleanUpFn = [];
278
- if (params.type !== client_1.ServerlessRoutines.still) {
279
- throw new Error('Params must be renderer');
280
- }
281
- try {
282
- await innerStillHandler(options, cleanUpFn);
283
- return { type: 'success' };
284
- }
285
- catch (err) {
286
- // If this error is encountered, we can just retry as it
287
- // is a very rare error to occur
288
- const isBrowserError = (0, is_flaky_error_1.isFlakyError)(err);
289
- const willRetry = isBrowserError || params.maxRetries > 0;
290
- renderer_1.RenderInternals.Log.error({
291
- indent: false,
292
- logLevel: params.logLevel,
293
- }, 'Got error:', err.stack, `Will retry = ${willRetry}`);
294
- if (params.streamed) {
295
- await options.onStream({
296
- type: 'error-occurred',
297
- payload: {
298
- error: err.stack,
299
- shouldRetry: willRetry,
300
- errorInfo: {
301
- name: err.name,
302
- message: err.message,
303
- stack: err.stack,
304
- chunk: null,
305
- frame: params.frame,
306
- type: 'renderer',
307
- isFatal: false,
308
- tmpDir: (0, serverless_1.getTmpDirStateIfENoSp)(err.stack, options.providerSpecifics),
309
- attempt: params.attempt,
310
- totalAttempts: 1 + params.maxRetries,
311
- willRetry,
312
- },
313
- },
314
- });
315
- }
316
- return {
317
- type: 'error',
318
- message: err.message,
319
- stack: err.stack,
320
- };
321
- }
322
- finally {
323
- (0, serverless_1.forgetBrowserEventLoop)(options.params.type === client_1.ServerlessRoutines.still
324
- ? options.params.logLevel
325
- : 'error');
326
- cleanUpFn.forEach((c) => c());
327
- }
328
- };
329
- exports.stillHandler = stillHandler;
@@ -1,2 +0,0 @@
1
- import type { getLambdaClient as original } from '../../shared/aws-clients';
2
- export declare const getLambdaClient: typeof original;
@@ -1,62 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getLambdaClient = void 0;
27
- const serverless_1 = require("@remotion/serverless");
28
- const mock_implementation_1 = require("../../test/mock-implementation");
29
- const getLambdaClient = (_region, timeoutInTest) => {
30
- return {
31
- config: {
32
- requestHandler: {},
33
- apiVersion: 'fake',
34
- },
35
- destroy: () => undefined,
36
- middlewareStack: undefined,
37
- send: async (params) => {
38
- const payload = JSON.parse(params.input.Payload);
39
- const { innerRoutine } = await Promise.resolve().then(() => __importStar(require('../../functions/index')));
40
- const responseStream = new serverless_1.ResponseStream();
41
- const prom = innerRoutine(payload, responseStream, {
42
- invokedFunctionArn: 'arn:fake',
43
- getRemainingTimeInMillis: () => timeoutInTest !== null && timeoutInTest !== void 0 ? timeoutInTest : 120000,
44
- awsRequestId: 'fake',
45
- }, mock_implementation_1.mockImplementation);
46
- if (params.input.InvocationType === 'RequestResponse' ||
47
- params.input.InvocationType === 'Event') {
48
- await prom;
49
- return { Payload: responseStream.getBufferedData() };
50
- }
51
- prom.then(() => {
52
- responseStream._finish();
53
- responseStream.end();
54
- });
55
- // When streaming, we should not consume the response
56
- return {
57
- EventStream: responseStream,
58
- };
59
- },
60
- };
61
- };
62
- exports.getLambdaClient = getLambdaClient;
@@ -1,2 +0,0 @@
1
- import type { bundle } from '@remotion/bundler';
2
- export declare const bundleSite: typeof bundle;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.bundleSite = void 0;
4
- const convertArgumentsIntoOptions = (args) => {
5
- var _a;
6
- if (args.length === 0) {
7
- throw new TypeError('bundle() was called without arguments');
8
- }
9
- const firstArg = args[0];
10
- if (typeof firstArg === 'string') {
11
- return {
12
- entryPoint: firstArg,
13
- onProgress: args[1],
14
- ...((_a = args[2]) !== null && _a !== void 0 ? _a : {}),
15
- };
16
- }
17
- if (typeof firstArg.entryPoint !== 'string') {
18
- throw new TypeError('bundle() was called without the `entryPoint` option');
19
- }
20
- return firstArg;
21
- };
22
- const bundleSite = (...args) => {
23
- const { entryPoint } = convertArgumentsIntoOptions(args);
24
- if (entryPoint === 'first') {
25
- return Promise.resolve('/path/to/bundle-1');
26
- }
27
- if (entryPoint === 'second') {
28
- return Promise.resolve('/path/to/bundle-2');
29
- }
30
- throw new Error('unknown entry');
31
- };
32
- exports.bundleSite = bundleSite;
@@ -1 +0,0 @@
1
- export declare const checkCredentials: () => undefined;
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkCredentials = void 0;
4
- const checkCredentials = () => undefined;
5
- exports.checkCredentials = checkCredentials;
@@ -1,2 +0,0 @@
1
- import type { getAccountId as original } from '../get-account-id';
2
- export declare const getAccountId: typeof original;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAccountId = void 0;
4
- const getAccountId = () => {
5
- const accountId = 'aws:iam::123456789'.match(/aws:iam::([0-9]+)/);
6
- if (!accountId) {
7
- throw new Error('Cannot get account ID');
8
- }
9
- return Promise.resolve(accountId[1]);
10
- };
11
- exports.getAccountId = getAccountId;
@@ -1,2 +0,0 @@
1
- import type { readDirectory as original } from '../../shared/read-dir';
2
- export declare const readDirectory: typeof original;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readDirectory = void 0;
4
- const upload_dir_1 = require("../../api/__mocks__/upload-dir");
5
- const readDirectory = ({ dir }) => {
6
- const files = (0, upload_dir_1.getDirFiles)(dir);
7
- const obj = {};
8
- for (const file of files) {
9
- obj[file.name] = () => Promise.resolve('etag');
10
- }
11
- return obj;
12
- };
13
- exports.readDirectory = readDirectory;
@@ -1,16 +0,0 @@
1
- import type { CloudProvider, OnMessage } from '@remotion/serverless';
2
- import type { ServerlessPayloads, ServerlessRoutines } from '@remotion/serverless/client';
3
- import type { LambdaReturnValues } from './return-values';
4
- type Options<T extends ServerlessRoutines, Provider extends CloudProvider> = {
5
- functionName: string;
6
- type: T;
7
- payload: Omit<ServerlessPayloads<Provider>[T], 'type'>;
8
- region: Provider['region'];
9
- timeoutInTest: number;
10
- };
11
- export declare const callLambda: <Provider extends CloudProvider, T extends ServerlessRoutines>(options: Options<T, Provider>) => Promise<LambdaReturnValues<Provider>[T]>;
12
- export declare const callLambdaWithStreaming: <Provider extends CloudProvider, T extends ServerlessRoutines>(options: Options<T, Provider> & {
13
- receivedStreamingPayload: OnMessage<Provider>;
14
- retriesRemaining: number;
15
- }) => Promise<void>;
16
- export {};
@@ -1,149 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.callLambdaWithStreaming = exports.callLambda = void 0;
4
- const client_lambda_1 = require("@aws-sdk/client-lambda");
5
- const client_1 = require("@remotion/serverless/client");
6
- const streaming_1 = require("@remotion/streaming");
7
- const aws_clients_1 = require("./aws-clients");
8
- const INVALID_JSON_MESSAGE = 'Cannot parse Lambda response as JSON';
9
- const parseJsonOrThrowSource = (data, type) => {
10
- const asString = new TextDecoder('utf-8').decode(data);
11
- try {
12
- return JSON.parse(asString);
13
- }
14
- catch (_a) {
15
- throw new Error(`Invalid JSON (${type}): ${asString}`);
16
- }
17
- };
18
- const callLambda = async (options) => {
19
- // Do not remove this await
20
- const res = await callLambdaWithoutRetry(options);
21
- if (res.type === 'error') {
22
- const err = new Error(res.message);
23
- err.stack = res.stack;
24
- throw err;
25
- }
26
- return res;
27
- };
28
- exports.callLambda = callLambda;
29
- const callLambdaWithStreaming = async (options) => {
30
- // As of August 2023, Lambda streaming sometimes misses parts of the JSON response.
31
- // Handling this for now by applying a retry mechanism.
32
- var _a;
33
- try {
34
- // Do not remove this await
35
- await callLambdaWithStreamingWithoutRetry(options);
36
- }
37
- catch (err) {
38
- if ((_a = err.stack) === null || _a === void 0 ? void 0 : _a.includes('TooManyRequestsException')) {
39
- throw new Error(`AWS Concurrency limit reached (Original Error: ${err.message}). See https://www.remotion.dev/docs/lambda/troubleshooting/rate-limit for tips to fix this.`);
40
- }
41
- if (!err.message.includes(INVALID_JSON_MESSAGE) &&
42
- !err.message.includes(LAMBDA_STREAM_STALL) &&
43
- !err.message.includes('aborted')) {
44
- throw err;
45
- }
46
- console.error('Retries remaining:', options.retriesRemaining);
47
- if (options.retriesRemaining === 0) {
48
- console.error('Throwing error:');
49
- throw err;
50
- }
51
- console.error(err);
52
- return (0, exports.callLambdaWithStreaming)({
53
- ...options,
54
- retriesRemaining: options.retriesRemaining - 1,
55
- });
56
- }
57
- };
58
- exports.callLambdaWithStreaming = callLambdaWithStreaming;
59
- const callLambdaWithoutRetry = async ({ functionName, type, payload, region, timeoutInTest, }) => {
60
- const Payload = JSON.stringify({ type, ...payload });
61
- const res = await (0, aws_clients_1.getLambdaClient)(region, timeoutInTest).send(new client_lambda_1.InvokeCommand({
62
- FunctionName: functionName,
63
- Payload,
64
- InvocationType: 'RequestResponse',
65
- }));
66
- const decoded = new TextDecoder('utf-8').decode(res.Payload);
67
- try {
68
- return JSON.parse(decoded);
69
- }
70
- catch (_a) {
71
- throw new Error(`Invalid JSON (${type}): ${JSON.stringify(decoded)}`);
72
- }
73
- };
74
- const STREAM_STALL_TIMEOUT = 30000;
75
- const LAMBDA_STREAM_STALL = `AWS did not invoke Lambda in ${STREAM_STALL_TIMEOUT}ms`;
76
- const invokeStreamOrTimeout = async ({ region, timeoutInTest, functionName, type, payload, }) => {
77
- const resProm = (0, aws_clients_1.getLambdaClient)(region, timeoutInTest).send(new client_lambda_1.InvokeWithResponseStreamCommand({
78
- FunctionName: functionName,
79
- Payload: JSON.stringify({ type, ...payload }),
80
- }));
81
- let cleanup = () => undefined;
82
- const timeout = new Promise((_resolve, reject) => {
83
- const int = setTimeout(() => {
84
- reject(new Error(LAMBDA_STREAM_STALL));
85
- }, STREAM_STALL_TIMEOUT);
86
- cleanup = () => {
87
- clearTimeout(int);
88
- };
89
- });
90
- const res = await Promise.race([resProm, timeout]);
91
- cleanup();
92
- return res;
93
- };
94
- const callLambdaWithStreamingWithoutRetry = async ({ functionName, type, payload, region, timeoutInTest, receivedStreamingPayload, }) => {
95
- const res = await invokeStreamOrTimeout({
96
- functionName,
97
- payload,
98
- region,
99
- timeoutInTest,
100
- type,
101
- });
102
- const { onData, clear } = (0, streaming_1.makeStreamer)((status, messageTypeId, data) => {
103
- const messageType = (0, client_1.messageTypeIdToMessageType)(messageTypeId);
104
- const innerPayload = client_1.formatMap[messageType] === 'json'
105
- ? parseJsonOrThrowSource(data, messageType)
106
- : data;
107
- const message = {
108
- successType: status,
109
- message: {
110
- type: messageType,
111
- payload: innerPayload,
112
- },
113
- };
114
- receivedStreamingPayload(message);
115
- });
116
- const dumpBuffers = () => {
117
- clear();
118
- };
119
- // @ts-expect-error - We are adding a listener to a global variable
120
- if (globalThis._dumpUnreleasedBuffers) {
121
- // @ts-expect-error - We are adding a listener to a global variable
122
- globalThis._dumpUnreleasedBuffers.addListener('dump-unreleased-buffers', dumpBuffers);
123
- }
124
- const events = res.EventStream;
125
- for await (const event of events) {
126
- // There are two types of events you can get on a stream.
127
- // `PayloadChunk`: These contain the actual raw bytes of the chunk
128
- // It has a single property: `Payload`
129
- if (event.PayloadChunk && event.PayloadChunk.Payload) {
130
- onData(event.PayloadChunk.Payload);
131
- }
132
- if (event.InvokeComplete) {
133
- if (event.InvokeComplete.ErrorCode) {
134
- const logs = `https://${region}.console.aws.amazon.com/cloudwatch/home?region=${region}#logsV2:logs-insights$3FqueryDetail$3D~(end~0~start~-3600~timeType~'RELATIVE~unit~'seconds~editorString~'fields*20*40timestamp*2c*20*40requestId*2c*20*40message*0a*7c*20filter*20*40requestId*20like*20*${res.$metadata.requestId}*22*0a*7c*20sort*20*40timestamp*20asc~source~(~'*2faws*2flambda*2f${functionName}))`;
135
- if (event.InvokeComplete.ErrorCode === 'Unhandled') {
136
- throw new Error(`Lambda function ${functionName} failed with an unhandled error: ${event.InvokeComplete.ErrorDetails} See ${logs} to see the logs of this invocation.`);
137
- }
138
- throw new Error(`Lambda function ${functionName} failed with error code ${event.InvokeComplete.ErrorCode}: ${event.InvokeComplete.ErrorDetails}. See ${logs} to see the logs of this invocation.`);
139
- }
140
- }
141
- // Don't put a `break` statement here, as it will cause the socket to not properly exit.
142
- }
143
- // @ts-expect-error - We are adding a listener to a global variable
144
- if (globalThis._dumpUnreleasedBuffers) {
145
- // @ts-expect-error - We are adding a listener to a global variable
146
- globalThis._dumpUnreleasedBuffers.removeListener('dump-unreleased-buffers', dumpBuffers);
147
- }
148
- clear();
149
- };
@@ -1,14 +0,0 @@
1
- import type { CloudProvider, ProviderSpecifics } from '@remotion/serverless';
2
- import { type SerializedInputProps } from '@remotion/serverless/client';
3
- export declare const cleanupSerializedInputProps: <Provider extends CloudProvider>({ serialized, region, providerSpecifics, forcePathStyle, }: {
4
- serialized: SerializedInputProps;
5
- region: Provider["region"];
6
- providerSpecifics: ProviderSpecifics<Provider>;
7
- forcePathStyle: boolean;
8
- }) => Promise<number>;
9
- export declare const cleanupSerializedResolvedProps: <Provider extends CloudProvider>({ serialized, region, providerSpecifics, forcePathStyle, }: {
10
- serialized: SerializedInputProps;
11
- region: Provider["region"];
12
- providerSpecifics: ProviderSpecifics<Provider>;
13
- forcePathStyle: boolean;
14
- }) => Promise<number>;