@remotion/lambda-client 4.0.364 → 4.0.365

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 (103) hide show
  1. package/dist/cjs/index.js +1 -1
  2. package/dist/esm/index.mjs +1 -1
  3. package/package.json +3 -3
  4. package/.turbo/turbo-formatting.log +0 -4
  5. package/.turbo/turbo-lint.log +0 -25
  6. package/.turbo/turbo-make.log +0 -3
  7. package/bundle.ts +0 -20
  8. package/dist/cjs/test/concurrency-payload.test.d.ts +0 -1
  9. package/dist/cjs/test/encode-aws-url.test.d.ts +0 -1
  10. package/dist/cjs/test/price-calculation.test.d.ts +0 -1
  11. package/dist/cjs/test/pricing.test.d.ts +0 -1
  12. package/dist/cjs/test/request-handler.test.d.ts +0 -1
  13. package/dist/cjs/test/validate-disk-size-in-mb.test.d.ts +0 -1
  14. package/dist/test/concurrency-payload.test.d.ts +0 -1
  15. package/dist/test/concurrency-payload.test.js +0 -119
  16. package/dist/test/encode-aws-url.test.d.ts +0 -1
  17. package/dist/test/encode-aws-url.test.js +0 -8
  18. package/dist/test/price-calculation.test.d.ts +0 -1
  19. package/dist/test/price-calculation.test.js +0 -62
  20. package/dist/test/pricing.test.d.ts +0 -1
  21. package/dist/test/pricing.test.js +0 -27
  22. package/dist/test/request-handler.test.d.ts +0 -1
  23. package/dist/test/request-handler.test.js +0 -36
  24. package/dist/test/validate-disk-size-in-mb.test.d.ts +0 -1
  25. package/dist/test/validate-disk-size-in-mb.test.js +0 -14
  26. package/dist/tsconfig.tsbuildinfo +0 -1
  27. package/eslint.config.mjs +0 -5
  28. package/src/app-router-webhook.ts +0 -73
  29. package/src/apply-lifecycle.ts +0 -30
  30. package/src/aws-clients.ts +0 -75
  31. package/src/aws-provider.ts +0 -139
  32. package/src/bucket-exists.ts +0 -35
  33. package/src/call-lambda-async.ts +0 -43
  34. package/src/call-lambda-streaming.ts +0 -226
  35. package/src/call-lambda-sync.ts +0 -59
  36. package/src/check-credentials.ts +0 -51
  37. package/src/clean-items.ts +0 -50
  38. package/src/constants.ts +0 -38
  39. package/src/content-disposition-header.ts +0 -64
  40. package/src/convert-to-serve-url.ts +0 -24
  41. package/src/create-bucket.ts +0 -87
  42. package/src/delete-file.ts +0 -38
  43. package/src/delete-function.ts +0 -28
  44. package/src/delete-render.ts +0 -114
  45. package/src/encode-aws-url-params.ts +0 -3
  46. package/src/estimate-price.ts +0 -95
  47. package/src/express-webhook.ts +0 -57
  48. package/src/get-account-id.ts +0 -22
  49. package/src/get-aws-client.ts +0 -63
  50. package/src/get-aws-urls.ts +0 -85
  51. package/src/get-buckets.ts +0 -84
  52. package/src/get-compositions-on-lambda.ts +0 -111
  53. package/src/get-credentials.ts +0 -81
  54. package/src/get-env-variable.ts +0 -15
  55. package/src/get-function-name.ts +0 -24
  56. package/src/get-function-version.ts +0 -49
  57. package/src/get-functions.ts +0 -114
  58. package/src/get-output-url-from-metadata.ts +0 -23
  59. package/src/get-render-progress.ts +0 -66
  60. package/src/get-s3-client.ts +0 -26
  61. package/src/get-service-client.ts +0 -195
  62. package/src/get-sites.ts +0 -136
  63. package/src/head-file.ts +0 -30
  64. package/src/index.ts +0 -152
  65. package/src/is-cli.ts +0 -7
  66. package/src/is-flaky-error.ts +0 -104
  67. package/src/is-in-lambda.ts +0 -5
  68. package/src/is-likely-to-have-aws-profile.ts +0 -55
  69. package/src/lambda-version-string.ts +0 -5
  70. package/src/lifecycle-rules.ts +0 -119
  71. package/src/lifecycle.ts +0 -44
  72. package/src/list-objects.ts +0 -87
  73. package/src/make-lambda-payload.ts +0 -328
  74. package/src/make-s3-url.ts +0 -13
  75. package/src/p-limit.ts +0 -75
  76. package/src/pages-router-webhook.ts +0 -68
  77. package/src/parse-function-name.ts +0 -24
  78. package/src/presign-url.ts +0 -121
  79. package/src/price-per-1s.ts +0 -863
  80. package/src/random-hash.ts +0 -10
  81. package/src/read-file.ts +0 -35
  82. package/src/regions.ts +0 -48
  83. package/src/render-media-on-lambda.ts +0 -227
  84. package/src/render-still-on-lambda.ts +0 -209
  85. package/src/runtime-preference.ts +0 -7
  86. package/src/speculate-function-name.ts +0 -60
  87. package/src/test/concurrency-payload.test.ts +0 -121
  88. package/src/test/encode-aws-url.test.ts +0 -7
  89. package/src/test/price-calculation.test.ts +0 -62
  90. package/src/test/pricing.test.ts +0 -32
  91. package/src/test/request-handler.test.ts +0 -42
  92. package/src/test/validate-disk-size-in-mb.test.ts +0 -15
  93. package/src/types.ts +0 -7
  94. package/src/validate-aws-region.ts +0 -14
  95. package/src/validate-bucketname.ts +0 -24
  96. package/src/validate-disk-size-in-mb.ts +0 -37
  97. package/src/validate-lambda-codec.ts +0 -28
  98. package/src/validate-memory-size.ts +0 -31
  99. package/src/validate-presign-expiration.ts +0 -46
  100. package/src/validate-serveurl.ts +0 -9
  101. package/src/validate-webhook-signature.ts +0 -42
  102. package/src/write-file.ts +0 -108
  103. package/tsconfig.json +0 -10
@@ -1,104 +0,0 @@
1
- export const isFlakyError = (err: Error): boolean => {
2
- const message = err.stack ?? '';
3
-
4
- // storage.googleapis.com sometimes returns 500s, and Video does not have retry on its own
5
- if (
6
- (message.includes('Format error') || message.includes('audio metadata')) &&
7
- message.includes('storage.googleapis.com')
8
- ) {
9
- return true;
10
- }
11
-
12
- if (message.includes('FATAL:zygote_communication_linux.cc')) {
13
- return true;
14
- }
15
-
16
- if (message.includes('error while loading shared libraries: libnss3.so')) {
17
- return true;
18
- }
19
-
20
- if (message.includes('but the server sent no data')) {
21
- return true;
22
- }
23
-
24
- if (message.includes('Compositor panicked')) {
25
- return true;
26
- }
27
-
28
- // S3 in rare occasions
29
- if (message.includes('We encountered an internal error.')) {
30
- return true;
31
- }
32
-
33
- if (message.includes('Compositor exited') && !message.includes('SIGSEGV')) {
34
- return true;
35
- }
36
-
37
- if (
38
- message.includes('Timed out') &&
39
- message.includes('while setting up the headless browser')
40
- ) {
41
- return true;
42
- }
43
-
44
- // https://github.com/remotion-dev/remotion/issues/2742
45
- if (message.includes('while trying to connect to the browser')) {
46
- return true;
47
- }
48
-
49
- // https://discord.com/channels/809501355504959528/1131234931863998665/1131998442219118622
50
- if (
51
- message.includes('RequestTimeout: Your socket connection to the server')
52
- ) {
53
- return true;
54
- }
55
-
56
- if (message.includes('waiting for the page to render the React component')) {
57
- return true;
58
- }
59
-
60
- // In puppeteer-evaluate.ts
61
- if (message.includes('Timed out evaluating page function')) {
62
- return true;
63
- }
64
-
65
- if (message.includes('Timeout exceeded rendering the component')) {
66
- return true;
67
- }
68
-
69
- // CDN slowness
70
- if (message.includes('Loading root component')) {
71
- return true;
72
- }
73
-
74
- // Internet flakiness
75
- if (
76
- message.includes('getaddrinfo') ||
77
- message.includes('ECONNRESET') ||
78
- message.includes('ERR_CONNECTION_TIMED_OUT') ||
79
- message.includes('ERR_NETWORK_CHANGED') ||
80
- message.includes('A network error occurred') ||
81
- message.includes('socket hang up')
82
- ) {
83
- return true;
84
- }
85
-
86
- if (message.includes('Target closed') || message.includes('Session closed')) {
87
- return true;
88
- }
89
-
90
- if (message.includes('SIGKILL')) {
91
- return true;
92
- }
93
-
94
- // ServiceException: We currently do not have sufficient capacity in the region you requested. Our system will be working on provisioning additional capacity. You can avoid getting this error by temporarily reducing your request rate.
95
- if (
96
- message.includes(
97
- 'ServiceException: We currently do not have sufficient capacity in the region you requested',
98
- )
99
- ) {
100
- return true;
101
- }
102
-
103
- return false;
104
- };
@@ -1,5 +0,0 @@
1
- export const isInsideLambda = () =>
2
- Boolean(
3
- typeof process !== 'undefined' &&
4
- process?.env?.__RESERVED_IS_INSIDE_REMOTION_LAMBDA,
5
- );
@@ -1,55 +0,0 @@
1
- import {readFileSync} from 'fs';
2
- import {homedir} from 'os';
3
- import {join, sep} from 'path';
4
- import {getEnvVariable} from './get-env-variable';
5
-
6
- const homeDirCache: Record<string, string> = {};
7
-
8
- const getHomeDirCacheKey = (): string => {
9
- // geteuid is only available on POSIX platforms (i.e. not Windows or Android).
10
- if (process && process.geteuid) {
11
- return `${process.geteuid()}`;
12
- }
13
-
14
- return 'DEFAULT';
15
- };
16
-
17
- const getHomeDir = (): string => {
18
- const {HOME, USERPROFILE, HOMEPATH, HOMEDRIVE = `C:${sep}`} = process.env;
19
-
20
- if (HOME) return HOME;
21
- if (USERPROFILE) return USERPROFILE;
22
- if (HOMEPATH) return `${HOMEDRIVE}${HOMEPATH}`;
23
-
24
- const homeDirCacheKey = getHomeDirCacheKey();
25
- if (!homeDirCache[homeDirCacheKey]) homeDirCache[homeDirCacheKey] = homedir();
26
-
27
- return homeDirCache[homeDirCacheKey];
28
- };
29
-
30
- const ENV_CREDENTIALS_PATH = 'AWS_SHARED_CREDENTIALS_FILE';
31
-
32
- // Logic is inline to https://github.com/smithy-lang/smithy-typescript/blob/main/packages/shared-ini-file-loader/src/getCredentialsFilepath.ts#L7
33
- const pathOfCredentialsFile = () => {
34
- return (
35
- getEnvVariable(ENV_CREDENTIALS_PATH) ||
36
- join(getHomeDir(), '.aws', 'credentials')
37
- );
38
- };
39
-
40
- export const isLikelyToHaveAwsProfile = (): boolean => {
41
- // Supabase uses Deno and does not support readFile
42
- // https://github.com/remotion-dev/remotion/issues/4844
43
- if (typeof Deno !== 'undefined') {
44
- return false;
45
- }
46
-
47
- const credentialsFile = pathOfCredentialsFile();
48
-
49
- try {
50
- const content = readFileSync(credentialsFile, 'utf-8');
51
- return content.includes('[default]');
52
- } catch {
53
- return false;
54
- }
55
- };
@@ -1,5 +0,0 @@
1
- import {VERSION} from '@remotion/serverless-client';
2
-
3
- export const LAMBDA_VERSION_STRING = VERSION.replace(/\./g, '-')
4
- .replace(/\+/g, '-')
5
- .substring(0, 10);
@@ -1,119 +0,0 @@
1
- import {
2
- DeleteBucketLifecycleCommand,
3
- PutBucketLifecycleConfigurationCommand,
4
- } from '@aws-sdk/client-s3';
5
- import type {CustomCredentials} from '@remotion/serverless-client';
6
- import {createLifeCycleInput, deleteLifeCycleInput} from './apply-lifecycle';
7
- import type {AwsProvider} from './aws-provider';
8
- import {getS3Client} from './get-s3-client';
9
- import {getLifeCycleRules} from './lifecycle';
10
- import type {AwsRegion} from './regions';
11
- import type {RequestHandler} from './types';
12
-
13
- const createLCRules = async ({
14
- bucketName,
15
- region,
16
- customCredentials,
17
- forcePathStyle,
18
- requestHandler,
19
- }: {
20
- bucketName: string;
21
- region: AwsRegion;
22
- customCredentials: CustomCredentials<AwsProvider> | null;
23
- forcePathStyle: boolean;
24
- requestHandler: RequestHandler | null;
25
- }) => {
26
- const lcRules = getLifeCycleRules();
27
- // create the lifecyle rules
28
- const createCommandInput = createLifeCycleInput({
29
- bucketName,
30
- lcRules,
31
- });
32
- const createCommand = new PutBucketLifecycleConfigurationCommand(
33
- createCommandInput,
34
- );
35
- try {
36
- await getS3Client({
37
- region,
38
- customCredentials,
39
- forcePathStyle,
40
- requestHandler,
41
- }).send(createCommand);
42
- } catch (err) {
43
- if ((err as Error).stack?.includes('AccessDenied')) {
44
- throw new Error(
45
- `You don't have the required permissions to create lifecycle rules on the bucket "${bucketName}", but the "enableFolderExpiry" was set to true. Ensure that your user has the "s3:PutLifecycleConfiguration" permission.`,
46
- );
47
- }
48
- }
49
- };
50
-
51
- const deleteLCRules = async ({
52
- bucketName,
53
- region,
54
- customCredentials,
55
- forcePathStyle,
56
- requestHandler,
57
- }: {
58
- bucketName: string;
59
- region: AwsRegion;
60
- customCredentials: CustomCredentials<AwsProvider> | null;
61
- forcePathStyle: boolean;
62
- requestHandler: RequestHandler | null;
63
- }) => {
64
- const deleteCommandInput = deleteLifeCycleInput({
65
- bucketName,
66
- });
67
- try {
68
- await getS3Client({
69
- region,
70
- customCredentials,
71
- forcePathStyle,
72
- requestHandler,
73
- }).send(new DeleteBucketLifecycleCommand(deleteCommandInput));
74
- } catch (err) {
75
- if ((err as Error).stack?.includes('AccessDenied')) {
76
- throw new Error(
77
- `You don't have the required permissions to delete lifecycle rules on the bucket "${bucketName}", but the "enableFolderExpiry" option was set to "false". Ensure that your user has the "s3:PutLifecycleConfiguration" permission. Set "enableFolderExpiry" to "null" to not overwrite any existing lifecycle rules.`,
78
- );
79
- }
80
- }
81
- };
82
-
83
- export const applyLifeCyleOperation = async ({
84
- enableFolderExpiry,
85
- bucketName,
86
- region,
87
- customCredentials,
88
- forcePathStyle,
89
- requestHandler,
90
- }: {
91
- enableFolderExpiry: boolean | null;
92
- bucketName: string;
93
- region: AwsRegion;
94
- customCredentials: CustomCredentials<AwsProvider> | null;
95
- forcePathStyle: boolean;
96
- requestHandler: RequestHandler | null;
97
- }) => {
98
- if (enableFolderExpiry === null) {
99
- return;
100
- }
101
-
102
- if (enableFolderExpiry === true) {
103
- await createLCRules({
104
- bucketName,
105
- region,
106
- customCredentials,
107
- forcePathStyle,
108
- requestHandler,
109
- });
110
- } else {
111
- await deleteLCRules({
112
- bucketName,
113
- region,
114
- customCredentials,
115
- forcePathStyle,
116
- requestHandler,
117
- });
118
- }
119
- };
package/src/lifecycle.ts DELETED
@@ -1,44 +0,0 @@
1
- import type {LifecycleRule} from '@aws-sdk/client-s3';
2
- import type {
3
- CloudProvider,
4
- DeleteAfter,
5
- ProviderSpecifics,
6
- } from '@remotion/serverless-client';
7
- import {expiryDays, truthy} from '@remotion/serverless-client';
8
-
9
- const getEnabledLifeCycleRule = ({
10
- key,
11
- value,
12
- }: {
13
- key: string;
14
- value: number;
15
- }): LifecycleRule => {
16
- return {
17
- Expiration: {
18
- Days: value,
19
- },
20
- Filter: {
21
- Prefix: `renders/${key}`,
22
- },
23
- ID: `delete-after-${key}`,
24
- Status: 'Enabled',
25
- };
26
- };
27
-
28
- export const getLifeCycleRules = (): LifecycleRule[] => {
29
- return Object.entries(expiryDays).map(([key, value]) =>
30
- getEnabledLifeCycleRule({key, value}),
31
- );
32
- };
33
-
34
- export const generateRandomHashWithLifeCycleRule = <
35
- Provider extends CloudProvider,
36
- >({
37
- deleteAfter,
38
- randomHashFn,
39
- }: {
40
- deleteAfter: DeleteAfter | null;
41
- randomHashFn: ProviderSpecifics<Provider>['randomHash'];
42
- }) => {
43
- return [deleteAfter, randomHashFn()].filter(truthy).join('-');
44
- };
@@ -1,87 +0,0 @@
1
- import {ListObjectsV2Command} from '@aws-sdk/client-s3';
2
- import type {ProviderSpecifics} from '@remotion/serverless-client';
3
- import type {AwsProvider} from './aws-provider';
4
- import {getS3Client} from './get-s3-client';
5
-
6
- export const lambdaLsImplementation: ProviderSpecifics<AwsProvider>['listObjects'] =
7
- async ({
8
- bucketName,
9
- prefix,
10
- region,
11
- expectedBucketOwner,
12
- continuationToken,
13
- forcePathStyle,
14
- requestHandler,
15
- }) => {
16
- try {
17
- const list = await getS3Client({
18
- region,
19
- customCredentials: null,
20
- forcePathStyle,
21
- requestHandler,
22
- }).send(
23
- new ListObjectsV2Command({
24
- Bucket: bucketName,
25
- Prefix: prefix,
26
- ExpectedBucketOwner: expectedBucketOwner ?? undefined,
27
- ContinuationToken: continuationToken,
28
- }),
29
- );
30
- if (list.NextContinuationToken) {
31
- return [
32
- ...(list.Contents ?? []).map((o) => {
33
- return {
34
- Key: o.Key as string,
35
- LastModified: o.LastModified as Date,
36
- ETag: o.ETag as string,
37
- Size: o.Size as number,
38
- };
39
- }),
40
- ...(await lambdaLsImplementation({
41
- bucketName,
42
- prefix,
43
- expectedBucketOwner,
44
- region,
45
- continuationToken: list.NextContinuationToken,
46
- forcePathStyle,
47
- requestHandler,
48
- })),
49
- ];
50
- }
51
-
52
- return (
53
- (list.Contents || [])?.map((o) => {
54
- return {
55
- Key: o.Key as string,
56
- LastModified: o.LastModified as Date,
57
- ETag: o.ETag as string,
58
- Size: o.Size as number,
59
- };
60
- }) ?? []
61
- );
62
- } catch (err) {
63
- if (!expectedBucketOwner) {
64
- throw err;
65
- }
66
-
67
- // Prevent from accessing a foreign bucket, retry without ExpectedBucketOwner and see if it works. If it works then it's an owner mismatch.
68
- if ((err as Error).stack?.includes('AccessDenied')) {
69
- await getS3Client({
70
- region,
71
- customCredentials: null,
72
- forcePathStyle,
73
- requestHandler,
74
- }).send(
75
- new ListObjectsV2Command({
76
- Bucket: bucketName,
77
- Prefix: prefix,
78
- }),
79
- );
80
- throw new Error(
81
- `Bucket owner mismatch: Expected the bucket ${bucketName} to be owned by you (AWS Account ID: ${expectedBucketOwner}) but it's not the case. Did you accidentially specify the wrong bucket?`,
82
- );
83
- }
84
-
85
- throw err;
86
- }
87
- };