{"record":{"id":"21e831eb33c092ff","repo":"remotion-dev/remotion","slug":"registerroot-was-called-more-than-once","errorCode":null,"errorMessage":"registerRoot() was called more than once.","messagePattern":"registerRoot\\(\\) was called more than once\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/core/src/register-root.ts","lineNumber":21,"sourceCode":"let Root: React.FC | null = null;\n\nlet listeners: ((comp: React.FC) => void)[] = [];\n\n/*\n * @description Registers the root component of the Remotion project.\n * @see [Documentation](https://www.remotion.dev/docs/register-root)\n */\nexport const registerRoot = (comp: React.FC) => {\n\tif (!comp) {\n\t\tthrow new Error(\n\t\t\t`You must pass a React component to registerRoot(), but ${JSON.stringify(\n\t\t\t\tcomp,\n\t\t\t)} was passed.`,\n\t\t);\n\t}\n\n\tif (Root) {\n\t\tthrow new Error('registerRoot() was called more than once.');\n\t}\n\n\tRoot = comp;\n\tlisteners.forEach((l) => {\n\t\tl(comp);\n\t});\n};\n\nexport const getRoot = () => {\n\treturn Root;\n};\n\nexport const waitForRoot = (fn: (comp: React.FC) => void): (() => void) => {\n\tif (Root) {\n\t\tfn(Root);\n\t\treturn () => undefined;\n\t}\n","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/core/src/register-root.ts#L3-L39","documentation":"Remotion expects exactly one registerRoot() call per entry bundle because it defines the single root of the composition tree. If `Root` is already set, a second call throws to prevent ambiguous registration.","triggerScenarios":"Two registerRoot() calls in the same bundle; an entry file imported twice causing side effects to re-run; HMR re-invoking the module; multiple entry points bundled together.","commonSituations":"Copy-paste leftover adding a second call; bundler config merging multiple entry files; stale HMR cache.","solutions":["Remove the duplicate registerRoot() call.","Ensure the entry file is imported/executed only once.","Check the bundler/CLI for multiple entry points pointing to the same module."],"exampleFix":"// before\nregisterRoot(RootA);\nregisterRoot(RootB);\n// after\nregisterRoot(RootA);","handlingStrategy":"validation","validationCode":"// Ensure only one entry invokes registerRoot; guard with a module flag\nif (!globalThis.__remotionRootRegistered) {\n  globalThis.__remotionRootRegistered = true;\n  registerRoot(Root);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a single registerRoot() call per entry bundle.","Avoid importing the entry module from multiple places.","Review bundler config for duplicate entry points."],"tags":["register-root","startup","entry-point"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}