{"record":{"id":"54159385b3f3d6c2","repo":"remotion-dev/remotion","slug":"the-mediaparsercontroller-was-used-in-multiple-p","errorCode":null,"errorMessage":"The mediaParserController() was used in multiple parseMedia() calls. Create a separate controller for each call.","messagePattern":"The mediaParserController\\(\\) was used in multiple parseMedia\\(\\) calls\\. Create a separate controller for each call\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/controller/media-parser-controller.ts","lineNumber":89,"sourceCode":"\n\t\treturn seekingHintResolution();\n\t};\n\n\tconst simulateSeek = (seekInSeconds: number) => {\n\t\tif (!simulateSeekResolution) {\n\t\t\tthrow new Error(\n\t\t\t\t'The mediaParserController() was not yet used in a parseMedia() call',\n\t\t\t);\n\t\t}\n\n\t\treturn simulateSeekResolution(seekInSeconds);\n\t};\n\n\tconst attachSeekingHintResolution = (\n\t\tcallback: () => Promise<SeekingHints | null>,\n\t) => {\n\t\tif (seekingHintResolution) {\n\t\t\tthrow new Error(\n\t\t\t\t'The mediaParserController() was used in multiple parseMedia() calls. Create a separate controller for each call.',\n\t\t\t);\n\t\t}\n\n\t\tseekingHintResolution = callback;\n\t};\n\n\tconst attachSimulateSeekResolution = (\n\t\tcallback: (seekInSeconds: number) => Promise<SeekResolution>,\n\t) => {\n\t\tif (simulateSeekResolution) {\n\t\t\tthrow new Error(\n\t\t\t\t'The mediaParserController() was used in multiple parseMedia() calls. Create a separate controller for each call.',\n\t\t\t);\n\t\t}\n\n\t\tsimulateSeekResolution = callback;\n\t};","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/controller/media-parser-controller.ts#L71-L107","documentation":"Thrown inside attachSeekingHintResolution when parseMedia tries to register its seeking-hints resolver on a controller that already has one. Because each controller is single-use, a second registration means the same controller was handed to a second parseMedia() call. The guard prevents the two parses from racing on one resolver.","triggerScenarios":"Passing the same controller instance to a second parseMedia() call while (or after) the first is still using it. Running parseMedia in a loop with a controller declared outside the loop.","commonSituations":"Building a player that re-parses when the source changes but reuses the controller variable. Concurrent parseMedia calls (e.g. video + separate audio) sharing one controller for shared abort/seek control. Hot-reload or React strict-mode double-invoke reusing a controller from module scope.","solutions":["Create a fresh mediaParserController() for every parseMedia() invocation; store it in component/request scope, not module scope.","If you need coordinated abort across multiple parses, share an AbortSignal via a single parent controller and create separate child controllers for each parseMedia call.","Abort and discard the old controller before starting a new parse: controller.abort() then make a new one."],"exampleFix":"// before\nconst controller = mediaParserController();\nawait parseMedia({src: a, controller});\nawait parseMedia({src: b, controller}); // throws\n\n// after\nconst ctrlA = mediaParserController();\nawait parseMedia({src: a, controller: ctrlA});\nconst ctrlB = mediaParserController();\nawait parseMedia({src: b, controller: ctrlB});","handlingStrategy":"validation","validationCode":"const makeRun = (src) => {\n  const controller = mediaParserController();\n  parseMedia({src, controller, fields: {duration: true}});\n  return controller;\n};\nconst c1 = makeRun(a); // separate controller per run\nconst c2 = makeRun(b);","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Instantiate mediaParserController inside the same scope as parseMedia.","Never share a controller across concurrent or sequential parseMedia calls.","On source change, abort and recreate the controller."],"tags":["controller","api-misuse","lifecycle","concurrency"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}