Skip to content

🎥 Make videos programmatically with React

retry

Jonny Burgered2ae068a5eb
diff --git a/packages/cloudrun/src/api/deploy-service.ts b/packages/cloudrun/src/api/deploy-service.ts
index e44a9e7762..acdf52af27 100644
--- a/packages/cloudrun/src/api/deploy-service.ts
+++ b/packages/cloudrun/src/api/deploy-service.ts
@@ -23,6 +23,7 @@ type InternalDeployServiceInput = {
projectID: string;
region: string;
logLevel: LogLevel;
+ indent: boolean;
};
export type DeployServiceInput = {
performImageVersionValidation?: boolean;
@@ -151,5 +152,6 @@ export const deployService = ({
projectID,
region,
logLevel: logLevel ?? 'info',
+ indent: false,
});
};
diff --git a/packages/cloudrun/src/api/deploy-site.ts b/packages/cloudrun/src/api/deploy-site.ts
index 6663581655..b4a7707edc 100644
--- a/packages/cloudrun/src/api/deploy-site.ts
+++ b/packages/cloudrun/src/api/deploy-site.ts
@@ -1,4 +1,5 @@
import type {GitSource, WebpackOverrideFn} from '@remotion/bundler';
+import type {LogLevel} from '@remotion/renderer';
import {NoReactAPIs} from '@remotion/renderer/pure';
import {cloudrunDeleteFile, cloudrunLs} from '../functions/helpers/io';
import {bundleSite} from '../shared/bundle-site';
@@ -12,21 +13,32 @@ import {getCloudStorageClient} from './helpers/get-cloud-storage-client';
import type {UploadDirProgress} from './upload-dir';
import {uploadDir} from './upload-dir';
+type Options = {
+ onBundleProgress?: (progress: number) => void;
+ onUploadProgress?: (upload: UploadDirProgress) => void;
+ webpackOverride?: WebpackOverrideFn;
+ ignoreRegisterRootWarning?: boolean;
+ enableCaching?: boolean;
+ publicDir?: string | null;
+ rootDir?: string;
+ bypassBucketNameValidation?: boolean;
+ gitSource?: GitSource | null;
+};
+
+export type RawDeploySiteInput = {
+ entryPoint: string;
+ bucketName: string;
+ siteName: string;
+ options: Options;
+ logLevel: LogLevel;
+ indent: boolean;
+};
+
export type DeploySiteInput = {
entryPoint: string;
bucketName: string;
siteName?: string;
- options?: {
- onBundleProgress?: (progress: number) => void;
- onUploadProgress?: (upload: UploadDirProgress) => void;
- webpackOverride?: WebpackOverrideFn;
- ignoreRegisterRootWarning?: boolean;
- enableCaching?: boolean;
- publicDir?: string | null;
- rootDir?: string;
- bypassBucketNameValidation?: boolean;
- gitSource?: GitSource | null;
- };
+ options?: Options;
};
export type DeploySiteOutput = Promise<{
@@ -39,23 +51,22 @@ export type DeploySiteOutput = Promise<{
};
}>;
-const deploySiteRaw = async ({
+const internalDeploySiteRaw = async ({
entryPoint,
bucketName,
siteName,
options,
-}: DeploySiteInput): DeploySiteOutput => {
+}: RawDeploySiteInput): DeploySiteOutput => {
validateBucketName(bucketName, {mustStartWithRemotion: true});
- const siteId = siteName ?? randomHash();
- validateSiteName(siteId);
+ validateSiteName(siteName);
const cloudStorageClient = getCloudStorageClient();
// check if bucket exists
await cloudStorageClient.bucket(bucketName).get();
- const subFolder = getSitesKey(siteId);
+ const subFolder = getSitesKey(siteName);
// gcpLs is a function that lists all files in a bucket
const [files, bundled] = await Promise.all([
@@ -102,7 +113,7 @@ const deploySiteRaw = async ({
return {
serveUrl: makeStorageServeUrl({bucketName, subFolder}),
- siteName: siteId,
+ siteName,
stats: {
uploadedFiles: toUpload.length,
deletedFiles: toDelete.length,
@@ -111,6 +122,8 @@ const deploySiteRaw = async ({
};
};
+const errorHandled = NoReactAPIs.wrapWithErrorHandling(internalDeploySiteRaw);
+
/**
* @description Deploys a Remotion project to a GCP storage bucket to prepare it for rendering on Cloud Run.
* @link https://remotion.dev/docs/cloudrun/deploysite
@@ -119,4 +132,13 @@ const deploySiteRaw = async ({
* @param {string} params.siteName The name of the folder in which the project gets deployed to.
* @param {object} params.options Further options, see documentation page for this function.
*/
-export const deploySite = NoReactAPIs.wrapWithErrorHandling(deploySiteRaw);
+export const deploySite = (input: DeploySiteInput): DeploySiteOutput => {
+ return errorHandled({
+ bucketName: input.bucketName,
+ entryPoint: input.entryPoint,
+ indent: false,
+ logLevel: 'info',
+ options: input.options ?? {},
+ siteName: input.siteName ?? randomHash(),
+ });
+};
diff --git a/packages/cloudrun/src/api/helpers/get-cloudrun-endpoint.ts b/packages/cloudrun/src/api/helpers/get-cloudrun-endpoint.ts
index 40f8b522e2..e4f829f05e 100644
--- a/packages/cloudrun/src/api/helpers/get-cloudrun-endpoint.ts
+++ b/packages/cloudrun/src/api/helpers/get-cloudrun-endpoint.ts
@@ -4,8 +4,8 @@ import {validateServiceName} from '../../shared/validate-service-name';
import {getServiceInfo} from '../get-service-info';
export type getCloudrunEndpointInput = {
- cloudRunUrl?: string;
- serviceName?: string;
+ cloudRunUrl?: string | null;
+ serviceName?: string | null;
region?: string;
};
diff --git a/packages/cloudrun/src/api/render-media-on-cloudrun.ts b/packages/cloudrun/src/api/render-media-on-cloudrun.ts
index 0dad95f06e..eafcafafff 100644
--- a/packages/cloudrun/src/api/render-media-on-cloudrun.ts
+++ b/packages/cloudrun/src/api/render-media-on-cloudrun.ts
@@ -2,6 +2,7 @@ import type {
AudioCodec,
ChromiumOptions,
FrameRange,
+ LogLevel,
PixelFormat,
ProResProfile,
ToOptions,
@@ -53,6 +54,8 @@ type InternalRenderMediaOnCloudrun = {
forceHeight?: number | null;
concurrency: number | string | null;
preferLossless: boolean | undefined;
+ indent: boolean;
+ logLevel: LogLevel;
} & Partial<ToOptions<typeof BrowserSafeApis.optionsMap.renderMediaOnCloudRun>>;
export type RenderMediaOnCloudrunInput = {
@@ -381,7 +384,7 @@ export const renderMediaOnCloudrun = ({
muted: muted ?? undefined,
forceWidth: forceWidth ?? null,
forceHeight: forceHeight ?? null,
- logLevel: logLevel ?? undefined,
+ logLevel: logLevel ?? 'info',
delayRenderTimeoutInMilliseconds:
delayRenderTimeoutInMilliseconds ?? undefined,
concurrency: concurrency ?? null,
@@ -389,5 +392,6 @@ export const renderMediaOnCloudrun = ({
preferLossless: preferLossless ?? undefined,
offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes ?? undefined,
colorSpace: colorSpace ?? undefined,
+ indent: false,
});
};
diff --git a/packages/cloudrun/src/api/render-still-on-cloudrun.ts b/packages/cloudrun/src/api/render-still-on-cloudrun.ts
index 16947b7780..61fa381404 100644
--- a/packages/cloudrun/src/api/render-still-on-cloudrun.ts
+++ b/packages/cloudrun/src/api/render-still-on-cloudrun.ts
@@ -7,6 +7,7 @@ import {BrowserSafeApis} from '@remotion/renderer/client';
import {NoReactAPIs} from '@remotion/renderer/pure';
import {NoReactInternals} from 'remotion/no-react';
import {VERSION} from 'remotion/version';
+import {DEFAULT_TIMEOUT} from '../defaults';
import type {
CloudRunCrashResponse,
CloudRunPayloadType,
@@ -20,23 +21,30 @@ import {getOrCreateBucket} from './get-or-create-bucket';
import {getAuthClientForUrl} from './helpers/get-auth-client-for-url';
import {getCloudrunEndpoint} from './helpers/get-cloudrun-endpoint';
-export type RenderStillOnCloudrunInput = {
- cloudRunUrl?: string;
- serviceName?: string;
+type MandatoryParameters = {
region: GcpRegion;
serveUrl: string;
composition: string;
- inputProps?: Record<string, unknown>;
- privacy?: 'public' | 'private';
- forceBucketName?: string;
- outName?: string;
imageFormat: StillImageFormat;
- envVariables?: Record<string, string>;
- frame?: number;
- chromiumOptions?: ChromiumOptions;
- forceWidth?: number | null;
- forceHeight?: number | null;
-} & Partial<ToOptions<typeof BrowserSafeApis.optionsMap.renderStillOnCloudRun>>;
+};
+
+type OptionalParameters = {
+ cloudRunUrl: string | null;
+ serviceName: string | null;
+ inputProps: Record<string, unknown>;
+ privacy: 'public' | 'private';
+ forceBucketName: string | null;
+ outName: string | null;
+ envVariables: Record<string, string>;
+ frame: number;
+ chromiumOptions: ChromiumOptions;
+ forceWidth: number | null;
+ forceHeight: number | null;
+ indent: boolean;
+} & ToOptions<typeof BrowserSafeApis.optionsMap.renderStillOnCloudRun>;
+
+export type RenderStillOnCloudrunInput = Partial<OptionalParameters> &
+ MandatoryParameters;
/**
* @description Triggers a render on a GCP Cloud Run service given a composition and a Cloud Run URL.
@@ -63,7 +71,7 @@ export type RenderStillOnCloudrunInput = {
* @returns {Promise<RenderStillOnCloudrunOutput>} See documentation for detailed structure
*/
-const renderStillOnCloudrunRaw = async ({
+const internalRenderStillOnCloudRun = async ({
cloudRunUrl,
serviceName,
region,
@@ -84,7 +92,7 @@ const renderStillOnCloudrunRaw = async ({
logLevel,
delayRenderTimeoutInMilliseconds,
offthreadVideoCacheSizeInBytes,
-}: RenderStillOnCloudrunInput): Promise<
+}: OptionalParameters & MandatoryParameters): Promise<
RenderStillOnCloudrunOutput | ErrorResponsePayload | CloudRunCrashResponse
> => {
validateServeUrl(serveUrl);
@@ -110,27 +118,26 @@ const renderStillOnCloudrunRaw = async ({
}).serializedString,
outputBucket,
outName,
- privacy: privacy ?? 'public',
+ privacy,
imageFormat,
- envVariables: envVariables ?? {},
+ envVariables,
jpegQuality,
chromiumOptions,
- scale: scale ?? 1,
+ scale,
forceWidth,
forceHeight,
- frame: frame ?? 0,
+ frame,
type: 'still',
- logLevel: logLevel ?? 'info',
- delayRenderTimeoutInMilliseconds:
- delayRenderTimeoutInMilliseconds ?? BrowserSafeApis.DEFAULT_TIMEOUT,
- offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes ?? null,
+ logLevel,
+ delayRenderTimeoutInMilliseconds,
+ offthreadVideoCacheSizeInBytes,
clientVersion: VERSION,
};
const client = await getAuthClientForUrl(cloudRunEndpoint);
const postResponse = await client.request({
- url: cloudRunUrl,
+ url: cloudRunEndpoint,
method: 'POST',
data,
responseType: 'stream',
@@ -202,6 +209,34 @@ const renderStillOnCloudrunRaw = async ({
return renderResponse;
};
-export const renderStillOnCloudrun = NoReactAPIs.wrapWithErrorHandling(
- renderStillOnCloudrunRaw,
-) as typeof renderStillOnCloudrunRaw;
+const errorHandled = NoReactAPIs.wrapWithErrorHandling(
+ internalRenderStillOnCloudRun,
+);
+
+export const renderStillOnCloudrun = (options: RenderStillOnCloudrunInput) => {
+ return errorHandled({
+ chromiumOptions: options.chromiumOptions ?? {},
+ cloudRunUrl: options.cloudRunUrl ?? null,
+ composition: options.composition,
+ delayRenderTimeoutInMilliseconds:
+ options.delayRenderTimeoutInMilliseconds ?? DEFAULT_TIMEOUT,
+ envVariables: options.envVariables ?? {},
+ forceBucketName: options.forceBucketName ?? null,
+ forceHeight: options.forceHeight ?? null,
+ forceWidth: options.forceWidth ?? null,
+ frame: options.frame ?? 0,
+ imageFormat: options.imageFormat,
+ indent: options.indent ?? false,
+ inputProps: options.inputProps ?? {},
+ jpegQuality: options.jpegQuality ?? BrowserSafeApis.DEFAULT_JPEG_QUALITY,
+ logLevel: options.logLevel ?? 'info',
+ offthreadVideoCacheSizeInBytes:
+ options.offthreadVideoCacheSizeInBytes ?? null,
+ outName: options.outName ?? null,
+ privacy: options.privacy ?? 'public',
+ region: options.region,
+ scale: options.scale ?? 1,
+ serveUrl: options.serveUrl,
+ serviceName: options.serviceName ?? null,
+ });
+};
diff --git a/packages/cloudrun/src/cli/commands/render/index.ts b/packages/cloudrun/src/cli/commands/render/index.ts
index 6fbeb766d4..902ae7d6ac 100644
--- a/packages/cloudrun/src/cli/commands/render/index.ts
+++ b/packages/cloudrun/src/cli/commands/render/index.ts
@@ -317,6 +317,7 @@ ${downloadName ? ` Downloaded File = ${downloadName}` : ''}
preferLossless: false,
offthreadVideoCacheSizeInBytes,
colorSpace,
+ indent: false,
});
if (res.type === 'crash') {
diff --git a/packages/cloudrun/src/cli/commands/services/deploy.ts b/packages/cloudrun/src/cli/commands/services/deploy.ts
index 325c2ceb18..995e885ca8 100644
--- a/packages/cloudrun/src/cli/commands/services/deploy.ts
+++ b/packages/cloudrun/src/cli/commands/services/deploy.ts
@@ -87,6 +87,7 @@ ${[
projectID,
region,
logLevel,
+ indent: false,
});
if (!deployResult.fullName) {
diff --git a/packages/cloudrun/src/cli/index.ts b/packages/cloudrun/src/cli/index.ts
index 1e67798b3a..d5f507828b 100644
--- a/packages/cloudrun/src/cli/index.ts
+++ b/packages/cloudrun/src/cli/index.ts
@@ -2,12 +2,12 @@ import {CliInternals} from '@remotion/cli';
import type {LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
import {parsedCloudrunCli} from './args';
-import {permissionsCommand, PERMISSIONS_COMMAND} from './commands/permissions';
-import {regionsCommand, REGIONS_COMMAND} from './commands/regions';
-import {renderCommand, RENDER_COMMAND} from './commands/render';
-import {servicesCommand, SERVICES_COMMAND} from './commands/services';
-import {sitesCommand, SITES_COMMAND} from './commands/sites';
-import {stillCommand, STILL_COMMAND} from './commands/still';
+import {PERMISSIONS_COMMAND, permissionsCommand} from './commands/permissions';
+import {REGIONS_COMMAND, regionsCommand} from './commands/regions';
+import {RENDER_COMMAND, renderCommand} from './commands/render';
+import {SERVICES_COMMAND, servicesCommand} from './commands/services';
+import {SITES_COMMAND, sitesCommand} from './commands/sites';
+import {STILL_COMMAND, stillCommand} from './commands/still';
import {printHelp} from './help';
import {quit} from './helpers/quit';
import {Log} from './log';
@@ -76,6 +76,7 @@ export const executeCommand = async (
name: error.name,
stack: error.stack,
stackFrame: frames,
+ page: null,
});
await CliInternals.printError(errorWithStackFrame, logLevel);
}
diff --git a/packages/cloudrun/src/functions/helpers/payloads.ts b/packages/cloudrun/src/functions/helpers/payloads.ts
index 2ac991576d..8840ebf8a9 100644
--- a/packages/cloudrun/src/functions/helpers/payloads.ts
+++ b/packages/cloudrun/src/functions/helpers/payloads.ts
@@ -70,7 +70,7 @@ export const CloudRunPayload = z.discriminatedUnion('type', [
envVariables: z.record(z.string()),
chromiumOptions: chromiumOptions.optional(),
outputBucket: z.string(),
- outName: z.string().optional(),
+ outName: z.string().nullable(),
frame: z.number(),
delayRenderTimeoutInMilliseconds: z.number(),
logLevel,
diff --git a/packages/core/src/RemotionRoot.tsx b/packages/core/src/RemotionRoot.tsx
index e4f5e3d268..ce4713aced 100644
--- a/packages/core/src/RemotionRoot.tsx
+++ b/packages/core/src/RemotionRoot.tsx
@@ -5,11 +5,11 @@ import React, {
useRef,
useState,
} from 'react';
+import {BufferingProvider} from './buffering.js';
import {CompositionManagerProvider} from './CompositionManager.js';
+import {continueRender, delayRender} from './delay-render.js';
import {EditorPropsProvider} from './EditorProps.js';
import {NativeLayersProvider} from './NativeLayers.js';
-import {BufferingProvider} from './buffering.js';
-import {continueRender, delayRender} from './delay-render.js';
import type {TNonceContext} from './nonce.js';
import {NonceContext} from './nonce.js';
import {PrefetchProvider} from './prefetch-state.js';
@@ -20,9 +20,9 @@ import type {
TimelineContextValue,
} from './timeline-position-state.js';
import {
+ getInitialFrameState,
SetTimelineContext,
TimelineContext,
- getInitialFrameState,
} from './timeline-position-state.js';
import {DurationsContextProvider} from './video/duration-state.js';
@@ -33,8 +33,8 @@ declare const __webpack_module__: {
};
export const RemotionRoot: React.FC<{
- children: React.ReactNode;
- numberOfAudioTags: number;
+ readonly children: React.ReactNode;
+ readonly numberOfAudioTags: number;
}> = ({children, numberOfAudioTags}) => {
const [remotionRootId] = useState(() => String(random(null)));
const [frame, setFrame] = useState<Record<string, number>>(() =>
@@ -49,7 +49,8 @@ export const RemotionRoot: React.FC<{
if (typeof window !== 'undefined') {
// eslint-disable-next-line react-hooks/rules-of-hooks
useLayoutEffect(() => {
- window.remotion_setFrame = (f: number, composition: string) => {
+ window.remotion_setFrame = (f: number, composition: string, attempt) => {
+ window.remotion_attempt = attempt;
const id = delayRender(`Setting the current frame to ${f}`);
setFrame((s) => ({
...s,
diff --git a/packages/core/src/delay-render.ts b/packages/core/src/delay-render.ts
index 572a38272a..a6e58c48aa 100644
--- a/packages/core/src/delay-render.ts
+++ b/packages/core/src/delay-render.ts
@@ -1,3 +1,4 @@
+import {cancelRender} from './cancel-render.js';
import {getRemotionEnvironment} from './get-remotion-environment.js';
import {truthy} from './truthy.js';
@@ -11,13 +12,15 @@ if (typeof window !== 'undefined') {
}
export const DELAY_RENDER_CALLSTACK_TOKEN = 'The delayRender was called:';
-export const DELAY_RENDER_RETRY_TOKEN = 'Rendering the frame will be retried.';
+export const DELAY_RENDER_RETRIES_LEFT = 'Retries left: ';
+export const DELAY_RENDER_RETRY_TOKEN =
+ '- Rendering the frame will be retried.';
const defaultTimeout = 30000;
export type DelayRenderOptions = {
timeoutInMilliseconds?: number;
- retry?: boolean;
+ retries?: number;
};
/**
@@ -43,11 +46,13 @@ export const delayRender = (
if (getRemotionEnvironment().isRendering) {
const timeoutToUse =
- (options?.timeoutInMilliseconds ?? typeof window === 'undefined'
- ? defaultTimeout
- : window.remotion_puppeteerTimeout ?? defaultTimeout) - 2000;
-
+ (options?.timeoutInMilliseconds ??
+ (typeof window === 'undefined'
+ ? defaultTimeout
+ : window.remotion_puppeteerTimeout ?? defaultTimeout)) - 2000;
if (typeof window !== 'undefined') {
+ const retriesLeft =
+ (options?.retries ?? 0) - (window.remotion_attempt - 1);
window.remotion_delayRenderTimeouts[handle] = {
label: label ?? null,
timeout: setTimeout(() => {
@@ -55,14 +60,15 @@ export const delayRender = (
`A delayRender()`,
label ? `"${label}"` : null,
`was called but not cleared after ${timeoutToUse}ms. See https://remotion.dev/docs/timeout for help.`,
+ retriesLeft > 0 ? DELAY_RENDER_RETRIES_LEFT + retriesLeft : null,
+ retriesLeft > 0 ? DELAY_RENDER_RETRY_TOKEN : null,
DELAY_RENDER_CALLSTACK_TOKEN,
- options?.retry ? DELAY_RENDER_RETRY_TOKEN : null,
called,
]
.filter(truthy)
.join(' ');
- throw new Error(message);
+ cancelRender(Error(message));
}, timeoutToUse),
};
}
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index ed20896f1e..1244aaba0f 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -44,8 +44,9 @@ declare global {
remotion_setFrame: (
frame: number,
composition: string,
- retriesLeft: number,
+ attempt: number,
) => void;
+ remotion_attempt: number;
remotion_initialFrame: number;
remotion_proxyPort: number;
remotion_audioEnabled: boolean;
diff --git a/packages/core/src/no-react.ts b/packages/core/src/no-react.ts
index 9b25dc49b3..6a3739a0cd 100644
--- a/packages/core/src/no-react.ts
+++ b/packages/core/src/no-react.ts
@@ -1,15 +1,16 @@
export type {TRenderAsset} from './CompositionManager';
-export type {ClipRegion} from './NativeLayers';
export {
EasingFunction,
ExtrapolateType,
- InterpolateOptions,
interpolate,
+ InterpolateOptions,
} from './interpolate';
-export {RandomSeed, random} from './random.js';
+export type {ClipRegion} from './NativeLayers';
+export {random, RandomSeed} from './random.js';
export type {VideoConfig} from './video-config';
import {
DELAY_RENDER_CALLSTACK_TOKEN,
+ DELAY_RENDER_RETRIES_LEFT,
DELAY_RENDER_RETRY_TOKEN,
} from './delay-render';
import {
@@ -40,6 +41,7 @@ export const NoReactInternals = {
deserializeJSONWithCustomFields,
DELAY_RENDER_CALLSTACK_TOKEN,
DELAY_RENDER_RETRY_TOKEN,
+ DELAY_RENDER_ATTEMPT_TOKEN: DELAY_RENDER_RETRIES_LEFT,
getOffthreadVideoSource,
getExpectedMediaFrameUncorrected,
};
diff --git a/packages/docs/docs/lambda/deploysite.md b/packages/docs/docs/lambda/deploysite.md
index b659603a9a..cfb91ae058 100644
--- a/packages/docs/docs/lambda/deploysite.md
+++ b/packages/docs/docs/lambda/deploysite.md
@@ -66,6 +66,11 @@ _optional_
Specify the subfolder in your S3 bucket that you want the site to deploy to. If you omit this property, a new subfolder with a random name will be created. If a site already exists with the name you passed, it will be overwritten. Can only contain the following characters: `0-9`, `a-z`, `A-Z`, `-`, `!`, `_`, `.`, `*`, `'`, `(`, `)`
+### `logLevel?`<AvailableFrom v="4.0.140"/>
+
+_optional_
+<Options id="log "/>
+
### `options?`
_optional_
diff --git a/packages/docs/docs/resources.md b/packages/docs/docs/resources.md
index 897b44f105..026989dd76 100644
--- a/packages/docs/docs/resources.md
+++ b/packages/docs/docs/resources.md
@@ -115,7 +115,7 @@ See the [Showcase](/showcase) for videos made with Remotion.
- [Formula 1 Graphics](https://www.youtube.com/watch?v=sA-X0Bw_7Gg&t=146s)
- [Remotion Skia Tutorial](https://www.youtube.com/watch?v=-7MOoWN2_nk)
- [Fireship: Remotion Tutorial](https://www.youtube.com/watch?v=deg8bOoziaE&t=3s)
-- [CRT effect](https://www.youtube.com/watch?v=-7MOoWN2_nk)
+- [CRT effect](https://www.youtube.com/watch?v=-7M OoWN2_nk)
- ["Create videos with Code" by Prismic](https://prismic.io/blog/create-videos-with-code-remotion-tutorial)
- [Integrate GreenSock with Remotion](https://archive.ph/dGQ19)
- [DVD Screensaver Tutorial](https://www.youtube.com/watch?v=n69siyttEwM)
diff --git a/packages/example/src/RetryDelayRender.tsx b/packages/example/src/RetryDelayRender.tsx
new file mode 100644
index 0000000000..69e8861afc
--- /dev/null
+++ b/packages/example/src/RetryDelayRender.tsx
@@ -0,0 +1,15 @@
+import {useEffect} from 'react';
+import {delayRender, useCurrentFrame} from 'remotion';
+
+export const RetryDelayRender: React.FC = () => {
+ const frame = useCurrentFrame();
+ useEffect(() => {
+ if (Math.random() < 0.6) {
+ delayRender('Retrying twice', {
+ timeoutInMilliseconds: 7000,
+ });
+ }
+ }, [frame]);
+
+ return null;
+};
diff --git a/packages/example/src/Root.tsx b/packages/example/src/Root.tsx
index 0e9b7e0e9a..a6ad441f42 100644
--- a/packages/example/src/Root.tsx
+++ b/packages/example/src/Root.tsx
@@ -40,6 +40,7 @@ import {PremountedExample} from './Premount';
import {PremountedRemoteVideos} from './Premount/RemoteVideos';
import InfinityVideo from './ReallyLongVideo';
import RemoteVideo from './RemoteVideo';
+import {RetryDelayRender} from './RetryDelayRender';
import RiveVehicle from './Rive/RiveExample';
import {ScalePath} from './ScalePath';
import {
@@ -1187,6 +1188,14 @@ export const Index: React.FC = () => {
width={1080}
durationInFrames={120}
/>
+ <Composition
+ id="RetryDelayRender"
+ component={RetryDelayRender}
+ fps={30}
+ height={1080}
+ width={1080}
+ durationInFrames={120}
+ />
</>
);
};
diff --git a/packages/it-tests/src/monorepo/go-package.test.ts b/packages/it-tests/src/monorepo/go-package.test.ts
index a7cb1ba171..fea1fc6acb 100644
--- a/packages/it-tests/src/monorepo/go-package.test.ts
+++ b/packages/it-tests/src/monorepo/go-package.test.ts
@@ -71,6 +71,7 @@ test("Go package should create the same payload as normal Lambda package", async
x264Preset: null,
inputProps: {},
preferLossless: false,
+ indent: false,
});
expect(removeUndefined(parsed)).toEqual(removeUndefined(nativeVersion));
diff --git a/packages/it-tests/src/monorepo/php-package.test.ts b/packages/it-tests/src/monorepo/php-package.test.ts
index 02e73b2001..b7baa96452 100644
--- a/packages/it-tests/src/monorepo/php-package.test.ts
+++ b/packages/it-tests/src/monorepo/php-package.test.ts
@@ -104,6 +104,7 @@ test("PHP package should create the same renderMedia payload as normal Lambda pa
webhook: null,
x264Preset: null,
preferLossless: false,
+ indent: false,
});
const jsonOutput = toParse.substring(0, toParse.lastIndexOf("}") + 1);
const parsedJson = JSON.parse(jsonOutput);
diff --git a/packages/it-tests/src/monorepo/python-package.test.ts b/packages/it-tests/src/monorepo/python-package.test.ts
index 8d3f30579e..1b7426fa1c 100644
--- a/packages/it-tests/src/monorepo/python-package.test.ts
+++ b/packages/it-tests/src/monorepo/python-package.test.ts
@@ -95,6 +95,7 @@ test("Python package should create the same renderMedia payload as normal Lambda
},
x264Preset: null,
preferLossless: false,
+ indent: false,
});
const jsonOutput = toParse.substring(0, toParse.lastIndexOf("}") + 1);
const parsedJson = JSON.parse(jsonOutput);
@@ -153,7 +154,7 @@ test("Python package should create the same renderStill payload as normal Lambda
deleteAfter: null,
downloadBehavior: { type: "play-in-browser" },
envVariables: {},
- forceBucketName: undefined,
+ forceBucketName: null,
forceHeight: null,
forceWidth: null,
imageFormat: "jpeg",
@@ -161,10 +162,15 @@ test("Python package should create the same renderStill payload as normal Lambda
logLevel: "info",
maxRetries: 1,
offthreadVideoCacheSizeInBytes: null,
- outName: undefined,
+ outName: null,
privacy: "public",
scale: 1,
timeoutInMilliseconds: 30000,
+ frame: 0,
+ indent: false,
+ onInit: () => undefined,
+ dumpBrowserLogs: false,
+ quality: undefined,
});
const jsonOutput = toParse.substring(0, toParse.lastIndexOf("}") + 1);
const parsedJson = JSON.parse(jsonOutput);
diff --git a/packages/lambda/src/api/deploy-function.ts b/packages/lambda/src/api/deploy-function.ts
index f4f0519063..8f8caf4d40 100644
--- a/packages/lambda/src/api/deploy-function.ts
+++ b/packages/lambda/src/api/deploy-function.ts
@@ -1,3 +1,4 @@
+import type {LogLevel} from '@remotion/renderer';
import {NoReactAPIs} from '@remotion/renderer/pure';
import {VERSION} from 'remotion/version';
import {getFunctions} from '../api/get-functions';
@@ -18,38 +19,44 @@ import {validateCloudWatchRetentionPeriod} from '../shared/validate-retention-pe
import {validateTimeout} from '../shared/validate-timeout';
import {createFunction} from './create-function';
-export type DeployFunctionInput = {
+type MandatoryParameters = {
createCloudWatchLogGroup: boolean;
cloudWatchLogRetentionPeriodInDays?: number;
region: AwsRegion;
timeoutInSeconds: number;
memorySizeInMb: number;
- diskSizeInMb?: number;
- customRoleArn?: string;
- enableLambdaInsights?: boolean;
};
+type OptionalParameters = {
+ diskSizeInMb: number;
+ customRoleArn: string | undefined;
+ enableLambdaInsights: boolean;
+ indent: boolean;
+ logLevel: LogLevel;
+};
+
+export type DeployFunctionInput = MandatoryParameters &
+ Partial<OptionalParameters>;
+
export type DeployFunctionOutput = {
functionName: string;
alreadyExisted: boolean;
};
-const deployFunctionRaw = async (
- params: DeployFunctionInput,
+const internalDeployFunction = async (
+ params: MandatoryParameters & OptionalParameters,
): Promise<DeployFunctionOutput> => {
- const diskSizeInMb = params.diskSizeInMb ?? DEFAULT_EPHEMERAL_STORAGE_IN_MB;
-
validateMemorySize(params.memorySizeInMb);
validateTimeout(params.timeoutInSeconds);
validateAwsRegion(params.region);
validateCloudWatchRetentionPeriod(params.cloudWatchLogRetentionPeriodInDays);
- validateDiskSizeInMb(diskSizeInMb);
+ validateDiskSizeInMb(params.diskSizeInMb);
validateCustomRoleArn(params.customRoleArn);
const fnNameRender = [
`${RENDER_FN_PREFIX}${LAMBDA_VERSION_STRING}`,
`mem${params.memorySizeInMb}mb`,
- `disk${diskSizeInMb}mb`,
+ `disk${params.diskSizeInMb}mb`,
`${params.timeoutInSeconds}sec`,
].join('-');
const accountId = await getAccountId({region: params.region});
@@ -64,7 +71,7 @@ const deployFunctionRaw = async (
f.version === VERSION &&
f.memorySizeInMb === params.memorySizeInMb &&
f.timeoutInSeconds === params.timeoutInSeconds &&
- f.diskSizeInMb === diskSizeInMb,
+ f.diskSizeInMb === params.diskSizeInMb,
);
const created = await createFunction({
@@ -79,7 +86,7 @@ const deployFunctionRaw = async (
params.cloudWatchLogRetentionPeriodInDays ??
DEFAULT_CLOUDWATCH_RETENTION_PERIOD,
alreadyCreated: Boolean(alreadyDeployed),
- ephemerealStorageInMb: diskSizeInMb,
+ ephemerealStorageInMb: params.diskSizeInMb,
customRoleArn: params.customRoleArn as string,
enableLambdaInsights: params.enableLambdaInsights ?? false,
});
@@ -94,6 +101,10 @@ const deployFunctionRaw = async (
};
};
+export const errorHandled = NoReactAPIs.wrapWithErrorHandling(
+ internalDeployFunction,
+);
+
/**
* @description Creates an AWS Lambda function in your account that will be able to render a video in the cloud.
* @see [Documentation](https://www.remotion.dev/docs/lambda/deployfunction)
@@ -106,7 +117,30 @@ const deployFunctionRaw = async (
* @param params.diskSizeInMb The amount of storage the function should be allocated. The higher, the longer videos you can render. Default 512.
* @returns {Promise<DeployFunctionOutput>} An object that contains the `functionName` property
*/
+export const deployFunction = ({
+ createCloudWatchLogGroup,
+ memorySizeInMb,
+ region,
+ timeoutInSeconds,
+ cloudWatchLogRetentionPeriodInDays,
+ customRoleArn,
+ enableLambdaInsights,
+ indent,
+ logLevel,
+ ...options
+}: DeployFunctionInput) => {
+ const diskSizeInMb = options.diskSizeInMb ?? DEFAULT_EPHEMERAL_STORAGE_IN_MB;
-export const deployFunction = NoReactAPIs.wrapWithErrorHandling(
- deployFunctionRaw,
-) as typeof deployFunctionRaw;
+ return errorHandled({
+ indent: indent ?? false,
+ logLevel: logLevel ?? 'info',
+ createCloudWatchLogGroup,
+ customRoleArn: customRoleArn ?? undefined,
+ diskSizeInMb,
+ enableLambdaInsights: enableLambdaInsights ?? false,
+ memorySizeInMb,
+ region,
+ timeoutInSeconds,
+ cloudWatchLogRetentionPeriodInDays,
+ });
+};
diff --git a/packages/lambda/src/api/deploy-site.ts b/packages/lambda/src/api/deploy-site.ts
index e816aafb3c..726dc58e10 100644
--- a/packages/lambda/src/api/deploy-site.ts
+++ b/packages/lambda/src/api/deploy-site.ts
@@ -1,4 +1,5 @@
import type {GitSource, WebpackOverrideFn} from '@remotion/bundler';
+import type {LogLevel} from '@remotion/renderer';
import {NoReactAPIs} from '@remotion/renderer/pure';
import fs from 'node:fs';
import {lambdaDeleteFile, lambdaLs} from '../functions/helpers/io';
@@ -34,6 +35,7 @@ export type DeploySiteInput = {
};
privacy?: 'public' | 'no-acl';
gitSource?: GitSource | null;
+ logLevel?: LogLevel;
};
export type DeploySiteOutput = Promise<{
@@ -46,7 +48,7 @@ export type DeploySiteOutput = Promise<{
};
}>;
-const deploySiteRaw = async ({
+const internalDeploySite = async ({
bucketName,
entryPoint,
siteName,
@@ -54,7 +56,10 @@ const deploySiteRaw = async ({
region,
privacy: passedPrivacy,
gitSource,
-}: DeploySiteInput): DeploySiteOutput => {
+}: DeploySiteInput & {
+ logLevel: LogLevel;
+ indent: boolean;
+}): DeploySiteOutput => {
validateAwsRegion(region);
validateBucketName(bucketName, {
mustStartWithRemotion: !options?.bypassBucketNameValidation,
@@ -144,6 +149,20 @@ const deploySiteRaw = async ({
};
};
+const deploySiteRaw = (args: DeploySiteInput) => {
+ return internalDeploySite({
+ bucketName: args.bucketName,
+ entryPoint: args.entryPoint,
+ region: args.region,
+ gitSource: args.gitSource,
+ options: args.options,
+ privacy: args.privacy,
+ siteName: args.siteName,
+ indent: false,
+ logLevel: 'info',
+ });
+};
+
/**
* @description Deploys a Remotion project to an S3 bucket to prepare it for rendering on AWS Lambda.
* @see [Documentation](https://remotion.dev/docs/lambda/deploysite)
@@ -154,5 +173,5 @@ const deploySiteRaw = async ({
* @param {object} params.options Further options, see documentation page for this function.
*/
export const deploySite = NoReactAPIs.wrapWithErrorHandling(
- deploySiteRaw,
+ internalDeploySite,
) as typeof deploySiteRaw;
diff --git a/packages/lambda/src/api/make-lambda-payload.ts b/packages/lambda/src/api/make-lambda-payload.ts
index 766b07ddd6..bc1c23f487 100644
--- a/packages/lambda/src/api/make-lambda-payload.ts
+++ b/packages/lambda/src/api/make-lambda-payload.ts
@@ -12,7 +12,7 @@ import type {
} from '@remotion/renderer';
import type {BrowserSafeApis} from '@remotion/renderer/client';
import {VERSION} from 'remotion/version';
-import type {AwsRegion, DeleteAfter, RenderStillOnLambdaInput} from '../client';
+import type {AwsRegion, DeleteAfter} from '../client';
import type {
LambdaPayloads,
LambdaStartPayload,
@@ -21,7 +21,7 @@ import type {
Privacy,
WebhookOption,
} from '../defaults';
-import {DEFAULT_MAX_RETRIES, LambdaRoutines} from '../defaults';
+import {LambdaRoutines} from '../defaults';
import {
compressInputProps,
getNeedsToUpload,
@@ -35,6 +35,7 @@ import {validateLambdaCodec} from '../shared/validate-lambda-codec';
import {validateServeUrl} from '../shared/validate-serveurl';
import {validateWebhook} from '../shared/validate-webhook';
import type {GetRenderProgressInput} from './get-render-progress';
+import type {RenderStillOnLambdaNonNullInput} from './render-still-on-lambda';
export type InnerRenderMediaOnLambdaInput = {
region: AwsRegion;
@@ -77,6 +78,7 @@ export type InnerRenderMediaOnLambdaInput = {
audioCodec: AudioCodec | null;
colorSpace: ColorSpace;
deleteAfter: DeleteAfter | null;
+ indent: boolean;
} & ToOptions<typeof BrowserSafeApis.optionsMap.renderMediaOnLambda>;
export const makeLambdaRenderMediaPayload = async ({
@@ -228,10 +230,11 @@ export const makeLambdaRenderStillPayload = async ({
forceHeight,
forceWidth,
forceBucketName,
- dumpBrowserLogs,
offthreadVideoCacheSizeInBytes,
deleteAfter,
-}: RenderStillOnLambdaInput): Promise<LambdaPayloads[LambdaRoutines.still]> => {
+}: RenderStillOnLambdaNonNullInput): Promise<
+ LambdaPayloads[LambdaRoutines.still]
+> => {
if (quality) {
throw new Error(
'The `quality` option is deprecated. Use `jpegQuality` instead.',
@@ -255,22 +258,22 @@ export const makeLambdaRenderStillPayload = async ({
imageFormat,
envVariables,
jpegQuality,
- maxRetries: maxRetries ?? DEFAULT_MAX_RETRIES,
- frame: frame ?? 0,
+ maxRetries,
+ frame,
privacy,
attempt: 1,
- logLevel: dumpBrowserLogs ? 'verbose' : logLevel ?? 'info',
- outName: outName ?? null,
- timeoutInMilliseconds: timeoutInMilliseconds ?? 30000,
- chromiumOptions: chromiumOptions ?? {},
- scale: scale ?? 1,
- downloadBehavior: downloadBehavior ?? {type: 'play-in-browser'},
+ logLevel,
+ outName,
+ timeoutInMilliseconds,
+ chromiumOptions,
+ scale,
+ downloadBehavior,
version: VERSION,
- forceHeight: forceHeight ?? null,
- forceWidth: forceWidth ?? null,
- bucketName: forceBucketName ?? null,
- offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes ?? null,
- deleteAfter: deleteAfter ?? null,
+ forceHeight,
+ forceWidth,
+ bucketName: forceBucketName,
+ offthreadVideoCacheSizeInBytes,
+ deleteAfter,
type: LambdaRoutines.still,
};
};
diff --git a/packages/lambda/src/api/render-media-on-lambda.ts b/packages/lambda/src/api/render-media-on-lambda.ts
index 0008ee447d..4e9a902e35 100644
--- a/packages/lambda/src/api/render-media-on-lambda.ts
+++ b/packages/lambda/src/api/render-media-on-lambda.ts
@@ -165,9 +165,14 @@ export const renderMediaOnLambdaOptionalToRequired = (
x264Preset: options.x264Preset ?? null,
deleteAfter: options.deleteAfter ?? null,
preferLossless: options.preferLossless ?? false,
+ indent: false,
};
};
+const wrapped = NoReactAPIs.wrapWithErrorHandling(
+ internalRenderMediaOnLambdaRaw,
+);
+
/**
* @description Triggers a render on a lambda given a composition and a lambda function.
* @see [Documentation](https://remotion.dev/docs/lambda/rendermediaonlambda)
@@ -190,9 +195,6 @@ export const renderMediaOnLambdaOptionalToRequired = (
export const renderMediaOnLambda = (
options: RenderMediaOnLambdaInput,
): Promise<RenderMediaOnLambdaOutput> => {
- const wrapped = NoReactAPIs.wrapWithErrorHandling(
- internalRenderMediaOnLambdaRaw,
- );
if (options.quality) {
throw new Error(
'quality has been renamed to jpegQuality. Please rename the option.',
diff --git a/packages/lambda/src/api/render-still-on-lambda.ts b/packages/lambda/src/api/render-still-on-lambda.ts
index b89e2b222d..cbfb71c68b 100644
--- a/packages/lambda/src/api/render-still-on-lambda.ts
+++ b/packages/lambda/src/api/render-still-on-lambda.ts
@@ -3,12 +3,16 @@ import type {
StillImageFormat,
ToOptions,
} from '@remotion/renderer';
-import type {BrowserSafeApis} from '@remotion/renderer/client';
+import {BrowserSafeApis} from '@remotion/renderer/client';
import {NoReactAPIs} from '@remotion/renderer/pure';
import type {AwsRegion} from '../pricing/aws-regions';
import {callLambda} from '../shared/call-lambda';
import type {CostsInfo, OutNameInput, Privacy} from '../shared/constants';
-import {LambdaRoutines} from '../shared/constants';
+import {
+ DEFAULT_MAX_RETRIES,
+ DEFAULT_TIMEOUT,
+ LambdaRoutines,
+} from '../shared/constants';
import type {DownloadBehavior} from '../shared/content-disposition-header';
import {
getCloudwatchMethodUrl,
@@ -16,7 +20,7 @@ import {
} from '../shared/get-aws-urls';
import {makeLambdaRenderStillPayload} from './make-lambda-payload';
-export type RenderStillOnLambdaInput = {
+type MandatoryParameters = {
region: AwsRegion;
functionName: string;
serveUrl: string;
@@ -24,29 +28,39 @@ export type RenderStillOnLambdaInput = {
inputProps: Record<string, unknown>;
imageFormat: StillImageFormat;
privacy: Privacy;
- maxRetries?: number;
- envVariables?: Record<string, string>;
+};
+
+type OptionalParameters = {
+ maxRetries: number;
+ envVariables: Record<string, string>;
/**
* @deprecated Renamed to `jpegQuality`
*/
quality?: never;
- frame?: number;
- outName?: OutNameInput;
- chromiumOptions?: ChromiumOptions;
- downloadBehavior?: DownloadBehavior;
- forceWidth?: number | null;
- forceHeight?: number | null;
- forceBucketName?: string;
+ frame: number;
+ outName: OutNameInput | null;
+ chromiumOptions: ChromiumOptions;
+ downloadBehavior: DownloadBehavior;
+ forceWidth: number | null;
+ forceHeight: number | null;
+ forceBucketName: string | null;
/**
- * @deprecated Renamed to `dumpBrowserLogs`
+ * @deprecated Renamed to `logLevel`
*/
- dumpBrowserLogs?: boolean;
- onInit?: (data: {
+ dumpBrowserLogs: boolean;
+ onInit: (data: {
renderId: string;
cloudWatchLogs: string;
lambdaInsightsUrl: string;
}) => void;
-} & Partial<ToOptions<typeof BrowserSafeApis.optionsMap.renderStillOnLambda>>;
+ indent: boolean;
+} & ToOptions<typeof BrowserSafeApis.optionsMap.renderStillOnLambda>;
+
+export type RenderStillOnLambdaNonNullInput = MandatoryParameters &
+ OptionalParameters;
+
+export type RenderStillOnLambdaInput = MandatoryParameters &
+ Partial<OptionalParameters>;
export type RenderStillOnLambdaOutput = {
estimatedPrice: CostsInfo;
@@ -57,8 +71,8 @@ export type RenderStillOnLambdaOutput = {
cloudWatchLogs: string;
};
-const renderStillOnLambdaRaw = async (
- input: RenderStillOnLambdaInput,
+const internalRenderStillOnLambda = async (
+ input: RenderStillOnLambdaNonNullInput,
): Promise<RenderStillOnLambdaOutput> => {
const {functionName, region, onInit} = input;
try {
@@ -69,7 +83,7 @@ const renderStillOnLambdaRaw = async (
region,
receivedStreamingPayload: (payload) => {
if (payload.type === 'render-id-determined') {
- onInit?.({
+ onInit({
renderId: payload.renderId,
cloudWatchLogs: getCloudwatchMethodUrl({
functionName,
@@ -114,6 +128,10 @@ const renderStillOnLambdaRaw = async (
}
};
+const errorHandled = NoReactAPIs.wrapWithErrorHandling(
+ internalRenderStillOnLambda,
+);
+
/**
* @description Renders a still frame on Lambda
* @link https://remotion.dev/docs/lambda/renderstillonlambda
@@ -130,6 +148,34 @@ const renderStillOnLambdaRaw = async (
* @param params.privacy Whether the item in the S3 bucket should be public. Possible values: `"private"` and `"public"`
* @returns {Promise<RenderStillOnLambdaOutput>} See documentation for exact response structure.
*/
-export const renderStillOnLambda = NoReactAPIs.wrapWithErrorHandling(
- renderStillOnLambdaRaw,
-) as typeof renderStillOnLambdaRaw;
+export const renderStillOnLambda = (input: RenderStillOnLambdaInput) => {
+ return errorHandled({
+ chromiumOptions: input.chromiumOptions ?? {},
+ composition: input.composition,
+ deleteAfter: input.deleteAfter ?? null,
+ downloadBehavior: input.downloadBehavior ?? {type: 'play-in-browser'},
+ envVariables: input.envVariables ?? {},
+ forceBucketName: input.forceBucketName ?? null,
+ forceHeight: input.forceHeight ?? null,
+ forceWidth: input.forceWidth ?? null,
+ frame: input.frame ?? 0,
+ functionName: input.functionName,
+ imageFormat: input.imageFormat,
+ indent: false,
+ inputProps: input.inputProps,
+ maxRetries: input.maxRetries ?? DEFAULT_MAX_RETRIES,
+ onInit: input.onInit ?? (() => undefined),
+ outName: input.outName ?? null,
+ privacy: input.privacy,
+ quality: undefined,
+ region: input.region,
+ serveUrl: input.serveUrl,
+ jpegQuality: input.jpegQuality ?? BrowserSafeApis.DEFAULT_JPEG_QUALITY,
+ logLevel: input.dumpBrowserLogs ? 'verbose' : input.logLevel ?? 'info',
+ offthreadVideoCacheSizeInBytes:
+ input.offthreadVideoCacheSizeInBytes ?? null,
+ scale: input.scale ?? 1,
+ timeoutInMilliseconds: input.timeoutInMilliseconds ?? DEFAULT_TIMEOUT,
+ dumpBrowserLogs: false,
+ });
+};
diff --git a/packages/lambda/src/cli/commands/render/render.ts b/packages/lambda/src/cli/commands/render/render.ts
index 9520200496..f7522024c1 100644
--- a/packages/lambda/src/cli/commands/render/render.ts
+++ b/packages/lambda/src/cli/commands/render/render.ts
@@ -325,6 +325,7 @@ export const renderCommand = async (
offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes ?? null,
x264Preset: x264Preset ?? null,
preferLossless,
+ indent: false,
});
const totalSteps = downloadName ? 6 : 5;
@@ -527,6 +528,7 @@ export const renderCommand = async (
name: err.name,
stack: err.stack,
stackFrame: frames,
+ page: null,
});
await CliInternals.printError(errorWithStackFrame, logLevel);
}
diff --git a/packages/lambda/src/cli/index.ts b/packages/lambda/src/cli/index.ts
index bbfd6df434..c4f77168e8 100644
--- a/packages/lambda/src/cli/index.ts
+++ b/packages/lambda/src/cli/index.ts
@@ -234,6 +234,7 @@ AWS returned an error message "The security token included in the request is inv
name: error.name,
stack: error.stack,
stackFrame: frames,
+ page: null,
});
await CliInternals.printError(errorWithStackFrame, logLevel);
}
diff --git a/packages/lambda/src/functions/renderer.ts b/packages/lambda/src/functions/renderer.ts
index b7483acd4a..6f06121acc 100644
--- a/packages/lambda/src/functions/renderer.ts
+++ b/packages/lambda/src/functions/renderer.ts
@@ -414,6 +414,7 @@ export const rendererHandler = async (
// is a very rare error to occur
const isRetryableError = isFlakyError(err as Error);
+ // TODO: Conflicts with retryability
const shouldNotRetry = (err as Error).name === 'CancelledError';
const willRetry =
diff --git a/packages/lambda/src/shared/constants.ts b/packages/lambda/src/shared/constants.ts
index 920d87fac3..ef73692513 100644
--- a/packages/lambda/src/shared/constants.ts
+++ b/packages/lambda/src/shared/constants.ts
@@ -397,7 +397,7 @@ export type LambdaPayloads = {
composition: string;
inputProps: SerializedInputProps;
imageFormat: StillImageFormat;
- envVariables: Record<string, string> | undefined;
+ envVariables: Record<string, string>;
attempt: number;
jpegQuality: number | undefined;
maxRetries: number;
diff --git a/packages/renderer/src/browser/BrowserPage.ts b/packages/renderer/src/browser/BrowserPage.ts
index b6fb60962d..8916b064bd 100644
--- a/packages/renderer/src/browser/BrowserPage.ts
+++ b/packages/renderer/src/browser/BrowserPage.ts
@@ -173,7 +173,7 @@ export class Page extends EventEmitter {
.send('Target.detachFromTarget', {
sessionId: event.sessionId,
})
- .catch((err) => console.log(err));
+ .catch((err) => Log.error({indent, logLevel}, err));
}
});
diff --git a/packages/renderer/src/client.ts b/packages/renderer/src/client.ts
index f52f8ff074..26a7f45f2f 100644
--- a/packages/renderer/src/client.ts
+++ b/packages/renderer/src/client.ts
@@ -11,6 +11,7 @@ import {
getFileExtensionFromCodec,
} from './get-extension-from-codec';
import {validStillImageFormats, validVideoImageFormats} from './image-format';
+import {DEFAULT_JPEG_QUALITY} from './jpeg-quality';
import {logLevels} from './log-level';
import {allOptions} from './options';
import {
@@ -51,6 +52,7 @@ export const BrowserSafeApis = {
validStillImageFormats,
DEFAULT_PIXEL_FORMAT,
DEFAULT_TIMEOUT,
+ DEFAULT_JPEG_QUALITY,
supportedAudioCodecs,
defaultFileExtensionMap,
defaultAudioCodecs,
diff --git a/packages/renderer/src/cycle-browser-tabs.ts b/packages/renderer/src/cycle-browser-tabs.ts
index 2c5645f1fc..b3c2317860 100644
--- a/packages/renderer/src/cycle-browser-tabs.ts
+++ b/packages/renderer/src/cycle-browser-tabs.ts
@@ -1,4 +1,5 @@
import type {LogLevel} from './log-level';
+import {Log} from './logger';
import type {BrowserReplacer} from './replace-browser';
export const cycleBrowserTabs = (
@@ -39,7 +40,7 @@ export const cycleBrowserTabs = (
}
})
- .catch((err) => console.log(err))
+ .catch((err) => Log.error({indent, logLevel}, err))
.finally(() => {
if (!stopped) {
set();
diff --git a/packages/renderer/src/error-handling/handle-javascript-exception.ts b/packages/renderer/src/error-handling/handle-javascript-exception.ts
index c8b320cf95..2563d00afa 100644
--- a/packages/renderer/src/error-handling/handle-javascript-exception.ts
+++ b/packages/renderer/src/error-handling/handle-javascript-exception.ts
@@ -114,6 +114,7 @@ export const handleJavascriptException = ({
frame,
name: errorType,
stack: exception.exceptionDetails.exception?.description,
+ page,
});
onError(symbolicatedErr);
};
diff --git a/packages/renderer/src/error-handling/symbolicateable-error.ts b/packages/renderer/src/error-handling/symbolicateable-error.ts
index fa8d929bdd..5215eae020 100644
--- a/packages/renderer/src/error-handling/symbolicateable-error.ts
+++ b/packages/renderer/src/error-handling/symbolicateable-error.ts
@@ -2,6 +2,7 @@
* A symbolicateable error is an error that can be symolicated by fetching the original sources. By throwing a symbolicateable error, Remotion CLI will attempt to symplicate it
*/
+import type {Page} from '../browser/BrowserPage';
import {parseDelayRenderEmbeddedStack} from '../delay-render-embedded-stack';
import type {UnsymbolicatedStackFrame} from '../parse-browser-error-stack';
@@ -9,6 +10,7 @@ export class SymbolicateableError extends Error {
stackFrame: UnsymbolicatedStackFrame[] | null;
delayRenderCall: UnsymbolicatedStackFrame[] | null;
frame: number | null;
+ page: Page | null;
constructor({
message,
@@ -16,18 +18,21 @@ export class SymbolicateableError extends Error {
stackFrame,
frame,
name,
+ page,
}: {
message: string;
stack: string | undefined;
frame: number | null;
name: string;
stackFrame: UnsymbolicatedStackFrame[] | null;
+ page: Page | null;
}) {
super(message);
this.stack = stack;
this.stackFrame = stackFrame;
this.frame = frame;
this.name = name;
+ this.page = page;
this.delayRenderCall = stack ? parseDelayRenderEmbeddedStack(stack) : null;
}
}
diff --git a/packages/renderer/src/is-delay-render-error-with.retry.ts b/packages/renderer/src/is-delay-render-error-with.retry.ts
new file mode 100644
index 0000000000..6e43fb4c02
--- /dev/null
+++ b/packages/renderer/src/is-delay-render-error-with.retry.ts
@@ -0,0 +1,47 @@
+import {NoReactInternals} from 'remotion/no-react';
+
+export const isDelayRenderErrorWithRetry = (error: Error | undefined) => {
+ if (!error) {
+ return false;
+ }
+
+ const shouldRetryError = (error as Error).stack?.includes(
+ NoReactInternals.DELAY_RENDER_RETRY_TOKEN,
+ );
+ return shouldRetryError;
+};
+
+export const getRetriesLeftFromError = (error: Error | undefined): number => {
+ if (!error) {
+ throw new Error('Expected stack');
+ }
+
+ const {stack} = error as Error;
+ if (!stack) {
+ throw new Error('Expected stack: ' + JSON.stringify(error));
+ }
+
+ const beforeIndex = stack.indexOf(
+ NoReactInternals.DELAY_RENDER_ATTEMPT_TOKEN,
+ );
+ if (beforeIndex === -1) {
+ throw new Error('Expected to find attempt token in stack');
+ }
+
+ const afterIndex = stack.indexOf(NoReactInternals.DELAY_RENDER_RETRY_TOKEN);
+
+ if (afterIndex === -1) {
+ throw new Error('Expected to find retry token in stack');
+ }
+
+ const inbetween = stack.substring(
+ beforeIndex + NoReactInternals.DELAY_RENDER_ATTEMPT_TOKEN.length,
+ afterIndex,
+ );
+ const parsed = Number(inbetween);
+ if (Number.isNaN(parsed)) {
+ throw new Error(`Expected to find a number in the stack ${stack}`);
+ }
+
+ return parsed;
+};
diff --git a/packages/renderer/src/test/get-assets-for-markup.tsx b/packages/renderer/src/test/get-assets-for-markup.tsx
index 1dbd5c16fd..37c1c77fed 100644
--- a/packages/renderer/src/test/get-assets-for-markup.tsx
+++ b/packages/renderer/src/test/get-assets-for-markup.tsx
@@ -130,7 +130,7 @@ export const getAssetsForMarkup = async (
currentFrame++
) {
act(() => {
- window.remotion_setFrame(currentFrame, ID, 0);
+ window.remotion_setFrame(currentFrame, ID, 1);
});
await waitForWindowToBeReady();
collectedAssets.push(collectAssets());
diff --git a/packages/renderer/src/wrap-with-error-handling.ts b/packages/renderer/src/wrap-with-error-handling.ts
index c2887ae3c8..eba29731c1 100644
--- a/packages/renderer/src/wrap-with-error-handling.ts
+++ b/packages/renderer/src/wrap-with-error-handling.ts
@@ -1,15 +1,26 @@
+import type {LogLevel} from './log-level';
import {printUsefulErrorMessage} from './print-useful-error-message';
type AsyncFunction<A extends unknown[], R> = (...args: A) => Promise<R>;
-export const wrapWithErrorHandling = <A extends unknown[], R>(
+type LogLevelAndIndentApi = {
+ logLevel: LogLevel;
+ indent: boolean;
+};
+
+export const wrapWithErrorHandling = <
+ A extends [LogLevelAndIndentApi, ...unknown[]],
+ R,
+>(
fn: AsyncFunction<A, R>,
): AsyncFunction<A, R> => {
return async (...args: A): Promise<R> => {
try {
return await fn(...args);
} catch (err) {
- printUsefulErrorMessage(err as Error, 'info');
+ const {indent} = args[0];
+ const {logLevel} = args[0];
+ printUsefulErrorMessage(err as Error, logLevel, indent);
throw err;
}
};