MCPcopy
hub / github.com/remotion-dev/remotion / delayRenderInternal

Function delayRenderInternal

packages/core/src/delay-render.ts:53–112  ·  view source on GitHub ↗
({
	scope,
	environment,
	label,
	options,
}: {
	scope: DelayRenderScope;
	environment: RemotionEnvironment;
	label: string | null;
	options: DelayRenderOptions;
})

Source from the content-addressed store, hash-verified

51 * @private
52 */
53export const delayRenderInternal = ({
54 scope,
55 environment,
56 label,
57 options,
58}: {
59 scope: DelayRenderScope;
60 environment: RemotionEnvironment;
61 label: string | null;
62 options: DelayRenderOptions;
63}): number => {
64 if (typeof label !== 'string' && label !== null) {
65 throw new Error(
66 'The label parameter of delayRender() must be a string or undefined, got: ' +
67 JSON.stringify(label),
68 );
69 }
70
71 const handle = Math.random();
72 scope.remotion_delayRenderHandles.push(handle);
73 const called = Error().stack?.replace(/^Error/g, '') ?? '';
74
75 if (environment.isRendering) {
76 const timeoutToUse =
77 (options?.timeoutInMilliseconds ??
78 scope.remotion_puppeteerTimeout ??
79 defaultTimeout) - 2000;
80 const retriesLeft = (options?.retries ?? 0) - (scope.remotion_attempt - 1);
81 scope.remotion_delayRenderTimeouts[handle] = {
82 label: label ?? null,
83 startTime: Date.now(),
84 timeout: setTimeout(() => {
85 const message = [
86 `A delayRender()`,
87 label ? `"${label}"` : null,
88 `was called but not cleared after ${timeoutToUse}ms. See https://remotion.dev/docs/timeout for help.`,
89 retriesLeft > 0 ? DELAY_RENDER_RETRIES_LEFT + retriesLeft : null,
90 retriesLeft > 0 ? DELAY_RENDER_RETRY_TOKEN : null,
91 DELAY_RENDER_CALLSTACK_TOKEN,
92 called,
93 ]
94 .filter(truthy)
95 .join(' ');
96
97 // in client-side rendering, don't throw (would be uncaught from setTimeout)
98 if (environment.isClientSideRendering) {
99 scope.remotion_cancelledError = getErrorStackWithMessage(
100 Error(message),
101 );
102 } else {
103 cancelRenderInternal(scope, Error(message));
104 }
105 }, timeoutToUse),
106 };
107 }
108
109 scope.remotion_renderReady = false;
110

Callers 2

delayRenderFunction · 0.85
useDelayRenderFunction · 0.85

Calls 5

ErrorInterface · 0.85
getErrorStackWithMessageFunction · 0.85
cancelRenderInternalFunction · 0.85
randomMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…