remotion-dev/remotion · error · TypeError
Effect config must contain only finite JSON values
Error message
Effect config must contain only finite JSON values
What it means
makeEffectDragData builds the drag payload for an effect and validates that the effect's config is a plain record containing only finite, JSON-safe values using the effectConfigSchema (z.record of z.json from zod/mini). Values like NaN, Infinity, undefined, functions, or class instances are not finite JSON and would break serialization for drag-and-drop, so a TypeError is thrown.
Solutions
- Sanitize the config before calling: replace NaN/Infinity with null or a finite sentinel and strip undefined/non-plain values
- Validate the config against the JSON schema yourself and surface a friendly message
- Clone the config through JSON.parse(JSON.stringify(...)) with a reviver that removes invalid values
Example fix
// before
makeEffectDragData({name: 'Blur', importPath: 'x', config: {amount: NaN}});
// after
makeEffectDragData({name: 'Blur', importPath: 'x', config: {amount: Number.isFinite(amount) ? amount : 0}}); Defensive patterns
Strategy: validation
Validate before calling
import * as z from 'zod/mini';
const cfg = z.safeParse(effectConfigSchema, effect.config);
if (!cfg.success) throw new Error('Effect config has non-JSON values: ' + JSON.stringify(cfg.error.issues)); Type guard
const isFiniteJson = (v: unknown): boolean => v === null || typeof v === 'string' || typeof v === 'boolean' || (typeof v === 'number' && Number.isFinite(v)) || (Array.isArray(v) && v.every(isFiniteJson)) || (typeof v === 'object' && v !== null && Object.values(v).every(isFiniteJson));
Try / catch
try {
const data = makeEffectDragData(effect);
} catch (e) {
if (e instanceof TypeError && String(e).includes('finite JSON values')) {
effect.config = sanitizeConfig(effect.config); // replace NaN/Infinity, strip undefined
} else throw e;
} Prevention
- Sanitize numeric props with Number.isFinite before building configs
- Strip undefined/functions from configs with a JSON round-trip
- Validate configs against the effectConfigSchema at effect-creation time, not drag time
When it happens
Trigger: Calling makeEffectDragData with an effect whose config contains non-JSON-safe values: NaN or Infinity numbers, undefined values, functions, Symbols, or non-plain objects.
Common situations: Effect props computed from division by zero or Math operations producing NaN/Infinity; passing live React state objects with functions; effect configs built from parsed data that kept undefined entries.
Related errors
- Could not serialize the passed input props to JSON
- A custom role ARN must either be "undefined" or a string…
- A "duration" of a spring is NaN, which it must not be
- A "duration" of a spring must be a "number" but is
- A "duration" of a spring must be finite, but is
AI-assisted analysis of remotion-dev/remotion@a6a7485a9a (2026-09-02).
Data as JSON: /api/errors/e86cd1641fb6d097.
Report an issue: GitHub.
Appendix: source
Thrown at packages/studio-protocol/src/effect-drag-data.ts:40
};
};
const effectConfigSchema = z.record(z.string(), z.json());
const effectDragDataSchema = z.object({
type: z.literal('remotion-effect'),
version: z.literal(1),
effect: z.object({
name: z.string(),
importPath: z.string(),
config: effectConfigSchema,
}),
});
export const makeEffectDragData = (
effect: EffectDragData['effect'],
): EffectDragData => {
if (!z.safeParse(effectConfigSchema, effect.config).success) {
throw new TypeError('Effect config must contain only finite JSON values');
}
return {
type: 'remotion-effect',
version: 1,
effect,
};
};
export const parseEffectDragData = (value: string): EffectDragData | null => {
try {
const parsed = z.safeParse(effectDragDataSchema, JSON.parse(value));
if (!parsed.success) {
return null;
}
return makeEffectDragData({
name: parsed.data.effect.name,View on GitHub (pinned to a6a7485a9a)