remotion-dev/remotion · error · Error

Invalid JSON: ${JSON.stringify(decoded)}

Error message

Invalid JSON: ${JSON.stringify(decoded)}

What it means

Thrown after UTF-8 decoding the sync response payload when JSON.parse fails. Means the function returned a body that is not valid JSON (e.g. an HTML error page, a plain string, or a truncated response). The decoded string is included via JSON.stringify.

Source

Thrown at packages/lambda-client/src/call-lambda-sync.ts:53

	if (res.FunctionError) {
		throw new Error(
			`Lambda function returned error: ${res.FunctionError} ${res.LogResult}`,
		);
	}

	if (!res.Payload) {
		throw new Error(
			`Lambda function returned no payload (status ${res.StatusCode})`,
		);
	}

	const decoded = new TextDecoder('utf-8').decode(res.Payload);

	try {
		return JSON.parse(decoded) as OrError<ServerlessReturnValues<Provider>[T]>;
	} catch {
		throw new Error(`Invalid JSON: ${JSON.stringify(decoded)}`);
	}
};

export const callFunctionSyncImplementation = async <
	Provider extends CloudProvider,
	T extends ServerlessRoutines,
>(
	options: CallFunctionOptions<T, Provider>,
): Promise<ServerlessReturnValues<Provider>[T]> => {
	const res = await callLambdaSyncWithoutRetry<T, Provider>(options);
	if (res.type === 'error') {
		const err = new Error(res.message);
		err.stack = res.stack;
		throw err;
	}

	return res;
};

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Redeploy the Lambda function so its version matches the lambda-client version you call with
  2. Inspect the decoded string embedded in the error to see what non-JSON body came back
  3. Ensure no proxy/CDN is rewriting the Lambda response body
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await getCompositionsOnLambda({...});
} catch (err) {
  if ((err as Error).message.startsWith('Invalid JSON:')) {
    // version mismatch — redeploy the function with the current lambda-client
  }
  throw err;
}

Prevention

When it happens

Trigger: Sync Lambda routine whose handler returned non-JSON, or whose response was rewritten/truncated before reaching the client.

Common situations: Version mismatch between lambda-client and the deployed function (different protocol), a proxy returning its own HTML error page, partially truncated payload.

Understand the failure class

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/072a8b226850de7e. Report an issue: GitHub.