🎥 Make videos programmatically with React
`@remotion/lambda` Disable Lambda leak detection slowing down renders
Jonny Burger949e69388fb7
diff --git a/packages/lambda/src/functions/renderer.ts b/packages/lambda/src/functions/renderer.tsindex 5314e69a3d..10716dfd64 100644--- a/packages/lambda/src/functions/renderer.ts+++ b/packages/lambda/src/functions/renderer.ts@@ -292,6 +292,8 @@ const renderHandler = async (return {};};+export const ENABLE_SLOW_LEAK_DETECTION = false;+export const rendererHandler = async (params: LambdaPayload,options: Options,@@ -305,7 +307,7 @@ export const rendererHandler = async (const logs: BrowserLog[] = [];- const leakDetection = enableNodeIntrospection();+ const leakDetection = enableNodeIntrospection(ENABLE_SLOW_LEAK_DETECTION);try {await renderHandler(params, options, logs);diff --git a/packages/lambda/src/shared/why-is-node-running.ts b/packages/lambda/src/shared/why-is-node-running.tsindex 4bf35f2ecd..5bec189b4c 100644--- a/packages/lambda/src/shared/why-is-node-running.ts+++ b/packages/lambda/src/shared/why-is-node-running.ts@@ -12,12 +12,21 @@ type Resource = {};export type NodeIntrospection = {- hook: asyncHooks.AsyncHook;+ hook: asyncHooks.AsyncHook | null;active: Map<number, Resource>;};-export const enableNodeIntrospection = (): NodeIntrospection => {+export const enableNodeIntrospection = (+ enabled: boolean,+): NodeIntrospection => {const active = new Map<number, Resource>();+ if (!enabled) {+ return {+ active,+ hook: null,+ };+ }+const hook = asyncHooks.createHook({init(asyncId, type, _triggerAsyncId, resource) {if (type === 'TIMERWRAP' || type === 'PROMISE') return;@@ -37,6 +46,10 @@ export const enableNodeIntrospection = (): NodeIntrospection => {};export function whyIsNodeRunning({active, hook}: NodeIntrospection) {+ if (!hook) {+ return;+ }+hook.disable();const activeResources = [...active.values()].filter((r) => {if (typeof r.resource.hasRef === 'function' && !r.resource.hasRef())