@remotion/lambda 4.0.63 → 4.0.66
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/functions/helpers/streaming-payloads.d.ts +3 -3
- package/dist/functions/renderer.js +16 -0
- package/dist/shared/stackback.d.ts +10 -0
- package/dist/shared/stackback.js +59 -0
- package/dist/shared/why-is-node-running.d.ts +17 -0
- package/dist/shared/why-is-node-running.js +79 -0
- package/package.json +8 -8
- package/remotionlambda-arm64.zip +0 -0
|
@@ -4,16 +4,16 @@ declare const streamingPayloadSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
4
4
|
type: z.ZodLiteral<"render-id-determined">;
|
|
5
5
|
renderId: z.ZodString;
|
|
6
6
|
}, "strip", z.ZodTypeAny, {
|
|
7
|
-
renderId: string;
|
|
8
7
|
type: "render-id-determined";
|
|
9
|
-
}, {
|
|
10
8
|
renderId: string;
|
|
9
|
+
}, {
|
|
11
10
|
type: "render-id-determined";
|
|
11
|
+
renderId: string;
|
|
12
12
|
}>]>;
|
|
13
13
|
export type StreamingPayloads = z.infer<typeof streamingPayloadSchema>;
|
|
14
14
|
export declare const isStreamingPayload: (str: string) => false | {
|
|
15
|
-
renderId: string;
|
|
16
15
|
type: "render-id-determined";
|
|
16
|
+
renderId: string;
|
|
17
17
|
};
|
|
18
18
|
export declare const sendProgressEvent: (responseStream: ResponseStream, payload: StreamingPayloads) => void;
|
|
19
19
|
export {};
|
|
@@ -13,16 +13,22 @@ const chunk_progress_1 = require("../shared/chunk-progress");
|
|
|
13
13
|
const compress_props_1 = require("../shared/compress-props");
|
|
14
14
|
const constants_1 = require("../shared/constants");
|
|
15
15
|
const is_flaky_error_1 = require("../shared/is-flaky-error");
|
|
16
|
+
const why_is_node_running_1 = require("../shared/why-is-node-running");
|
|
16
17
|
const get_browser_instance_1 = require("./helpers/get-browser-instance");
|
|
17
18
|
const get_chromium_executable_path_1 = require("./helpers/get-chromium-executable-path");
|
|
18
19
|
const get_current_region_1 = require("./helpers/get-current-region");
|
|
19
20
|
const io_1 = require("./helpers/io");
|
|
20
21
|
const on_downloads_logger_1 = require("./helpers/on-downloads-logger");
|
|
21
22
|
const write_lambda_error_1 = require("./helpers/write-lambda-error");
|
|
23
|
+
let leakDetectionTimeout = null;
|
|
22
24
|
const renderHandler = async (params, options, logs) => {
|
|
23
25
|
if (params.type !== constants_1.LambdaRoutines.renderer) {
|
|
24
26
|
throw new Error('Params must be renderer');
|
|
25
27
|
}
|
|
28
|
+
if (leakDetectionTimeout !== null) {
|
|
29
|
+
clearTimeout(leakDetectionTimeout);
|
|
30
|
+
leakDetectionTimeout = null;
|
|
31
|
+
}
|
|
26
32
|
if (params.launchFunctionConfig.version !== version_1.VERSION) {
|
|
27
33
|
throw new Error(`The version of the function that was specified as "rendererFunctionName" is ${version_1.VERSION} but the version of the function that invoked the render is ${params.launchFunctionConfig.version}. Please make sure that the version of the function that is specified as "rendererFunctionName" is the same as the version of the function that is invoked.`);
|
|
28
34
|
}
|
|
@@ -217,6 +223,7 @@ const rendererHandler = async (params, options) => {
|
|
|
217
223
|
throw new Error('Params must be renderer');
|
|
218
224
|
}
|
|
219
225
|
const logs = [];
|
|
226
|
+
const leakDetection = (0, why_is_node_running_1.enableNodeIntrospection)();
|
|
220
227
|
try {
|
|
221
228
|
await renderHandler(params, options, logs);
|
|
222
229
|
return {
|
|
@@ -275,6 +282,15 @@ const rendererHandler = async (params, options) => {
|
|
|
275
282
|
}
|
|
276
283
|
finally {
|
|
277
284
|
(0, get_browser_instance_1.forgetBrowserEventLoop)(params.logLevel);
|
|
285
|
+
leakDetectionTimeout = setTimeout(() => {
|
|
286
|
+
console.log('Leak detected: Lambda function is still running 10s after the render has finished.');
|
|
287
|
+
console.log('You may report this to the Remotion team.');
|
|
288
|
+
console.log('Include the logs below:');
|
|
289
|
+
(0, why_is_node_running_1.whyIsNodeRunning)(leakDetection);
|
|
290
|
+
console.log('Force-quitting the Lambda function now.');
|
|
291
|
+
process.exit(0);
|
|
292
|
+
}, 10000);
|
|
293
|
+
leakDetectionTimeout.unref();
|
|
278
294
|
}
|
|
279
295
|
};
|
|
280
296
|
exports.rendererHandler = rendererHandler;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
/// <reference types="node" />
|
|
5
|
+
export declare const stackback: (error: Error) => NodeJS.CallSite[];
|
|
6
|
+
declare global {
|
|
7
|
+
interface Error {
|
|
8
|
+
_sb_callsites: NodeJS.CallSite[];
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stackback = void 0;
|
|
4
|
+
function FormatStackTrace(error, frames) {
|
|
5
|
+
const lines = [];
|
|
6
|
+
try {
|
|
7
|
+
lines.push(error.toString());
|
|
8
|
+
}
|
|
9
|
+
catch (e) {
|
|
10
|
+
try {
|
|
11
|
+
lines.push('<error: ' + e + '>');
|
|
12
|
+
}
|
|
13
|
+
catch (ee) {
|
|
14
|
+
lines.push('<error>');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
for (let i = 0; i < frames.length; i++) {
|
|
18
|
+
const frame = frames[i];
|
|
19
|
+
let line;
|
|
20
|
+
try {
|
|
21
|
+
line = frame.toString();
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
try {
|
|
25
|
+
line = '<error: ' + e + '>';
|
|
26
|
+
}
|
|
27
|
+
catch (ee) {
|
|
28
|
+
// Any code that reaches this point is seriously nasty!
|
|
29
|
+
line = '<error>';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
lines.push(' at ' + line);
|
|
33
|
+
}
|
|
34
|
+
return lines.join('\n');
|
|
35
|
+
}
|
|
36
|
+
const stackback = (error) => {
|
|
37
|
+
// save original stacktrace
|
|
38
|
+
const save = Error.prepareStackTrace;
|
|
39
|
+
// replace capture with our function
|
|
40
|
+
Error.prepareStackTrace = function (err, trace) {
|
|
41
|
+
// cache stack frames so we don't have to get them again
|
|
42
|
+
// use a non-enumerable property
|
|
43
|
+
Object.defineProperty(err, '_sb_callsites', {
|
|
44
|
+
value: trace,
|
|
45
|
+
});
|
|
46
|
+
return (save || FormatStackTrace)(err, trace);
|
|
47
|
+
};
|
|
48
|
+
// force capture of the stack frames
|
|
49
|
+
// eslint-disable-next-line no-unused-expressions
|
|
50
|
+
error.stack;
|
|
51
|
+
// someone already asked for the stack so we can't do this trick
|
|
52
|
+
if (!error._sb_callsites) {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
// return original capture function
|
|
56
|
+
Error.prepareStackTrace = save;
|
|
57
|
+
return error._sb_callsites;
|
|
58
|
+
};
|
|
59
|
+
exports.stackback = stackback;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import asyncHooks from 'async_hooks';
|
|
4
|
+
type Resource = {
|
|
5
|
+
type: string;
|
|
6
|
+
stacks: NodeJS.CallSite[];
|
|
7
|
+
resource: {
|
|
8
|
+
hasRef?: () => boolean;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
type NodeIntrospection = {
|
|
12
|
+
hook: asyncHooks.AsyncHook;
|
|
13
|
+
active: Map<number, Resource>;
|
|
14
|
+
};
|
|
15
|
+
export declare const enableNodeIntrospection: () => NodeIntrospection;
|
|
16
|
+
export declare function whyIsNodeRunning({ active, hook }: NodeIntrospection): void;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
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.whyIsNodeRunning = exports.enableNodeIntrospection = void 0;
|
|
7
|
+
const async_hooks_1 = __importDefault(require("async_hooks"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const stackback_1 = require("./stackback");
|
|
11
|
+
const enableNodeIntrospection = () => {
|
|
12
|
+
const active = new Map();
|
|
13
|
+
const hook = async_hooks_1.default.createHook({
|
|
14
|
+
init(asyncId, type, _triggerAsyncId, resource) {
|
|
15
|
+
if (type === 'TIMERWRAP' || type === 'PROMISE')
|
|
16
|
+
return;
|
|
17
|
+
if (type === 'PerformanceObserver' || type === 'RANDOMBYTESREQUEST')
|
|
18
|
+
return;
|
|
19
|
+
const err = new Error('whatevs');
|
|
20
|
+
const stacks = (0, stackback_1.stackback)(err);
|
|
21
|
+
active.set(asyncId, { type, stacks, resource });
|
|
22
|
+
},
|
|
23
|
+
destroy(asyncId) {
|
|
24
|
+
active.delete(asyncId);
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
hook.enable();
|
|
28
|
+
return { hook, active };
|
|
29
|
+
};
|
|
30
|
+
exports.enableNodeIntrospection = enableNodeIntrospection;
|
|
31
|
+
function whyIsNodeRunning({ active, hook }) {
|
|
32
|
+
hook.disable();
|
|
33
|
+
const activeResources = [...active.values()].filter((r) => {
|
|
34
|
+
if (typeof r.resource.hasRef === 'function' && !r.resource.hasRef())
|
|
35
|
+
return false;
|
|
36
|
+
return true;
|
|
37
|
+
});
|
|
38
|
+
console.error('There are %d handle(s) keeping the process running', activeResources.length);
|
|
39
|
+
function printStacks(o) {
|
|
40
|
+
const stacks = o.stacks.slice(1).filter((s) => {
|
|
41
|
+
const filename = s.getFileName();
|
|
42
|
+
return (filename &&
|
|
43
|
+
filename.indexOf(path_1.sep) > -1 &&
|
|
44
|
+
filename.indexOf('internal' + path_1.sep) !== 0);
|
|
45
|
+
});
|
|
46
|
+
console.error('');
|
|
47
|
+
console.error('# %s', o.type);
|
|
48
|
+
if (stacks[0]) {
|
|
49
|
+
let padding = '';
|
|
50
|
+
stacks.forEach((s) => {
|
|
51
|
+
const pad = (s.getFileName() + ':' + s.getLineNumber()).replace(/./g, ' ');
|
|
52
|
+
if (pad.length > padding.length)
|
|
53
|
+
padding = pad;
|
|
54
|
+
});
|
|
55
|
+
stacks.forEach((s) => {
|
|
56
|
+
const prefix = s.getFileName() + ':' + s.getLineNumber();
|
|
57
|
+
try {
|
|
58
|
+
const src = fs_1.default
|
|
59
|
+
.readFileSync(s.getFileName(), 'utf-8')
|
|
60
|
+
.split(/\n|\r\n/);
|
|
61
|
+
console.error(prefix +
|
|
62
|
+
padding.slice(prefix.length) +
|
|
63
|
+
' - ' +
|
|
64
|
+
src[s.getLineNumber() - 1].trim());
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
console.error(prefix + padding.slice(prefix.length));
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
console.error('(unknown stack trace)');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
for (const o of activeResources) {
|
|
76
|
+
printStacks(o);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.whyIsNodeRunning = whyIsNodeRunning;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/lambda",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.66",
|
|
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.22.3",
|
|
29
|
-
"@remotion/bundler": "4.0.
|
|
30
|
-
"@remotion/
|
|
31
|
-
"remotion": "4.0.
|
|
32
|
-
"@remotion/
|
|
29
|
+
"@remotion/bundler": "4.0.66",
|
|
30
|
+
"@remotion/cli": "4.0.66",
|
|
31
|
+
"remotion": "4.0.66",
|
|
32
|
+
"@remotion/renderer": "4.0.66"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@jonny/eslint-config": "3.0.276",
|
|
@@ -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.
|
|
47
|
-
"@remotion/compositor-linux-arm64-gnu": "4.0.
|
|
46
|
+
"@remotion/bundler": "4.0.66",
|
|
47
|
+
"@remotion/compositor-linux-arm64-gnu": "4.0.66"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@remotion/bundler": "4.0.
|
|
50
|
+
"@remotion/bundler": "4.0.66"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
package/remotionlambda-arm64.zip
CHANGED
|
Binary file
|