{"record":{"id":"dc6bbf0acf24d571","repo":"remotion-dev/remotion","slug":"could-not-reorder-sequence","errorCode":null,"errorMessage":"Could not reorder sequence","messagePattern":"Could not reorder sequence","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/browser-studio/src/browser-studio-operations.ts","lineNumber":1546,"sourceCode":"\t\t\t\tposition,\n\t\t\t\tformatFile: formatCodemodFile,\n\t\t\t});\n\t\t\tconst nodePathMutation = controller.applyMutation({\n\t\t\t\ttimelineSelection: null,\n\t\t\t\tfileName: absolutePath,\n\t\t\t\tmutate: () => ({\n\t\t\t\t\t...project,\n\t\t\t\t\tfiles: {...project.files, [absolutePath]: result.output},\n\t\t\t\t}),\n\t\t\t\tnodePathMutationFiles: [\n\t\t\t\t\t{\n\t\t\t\t\t\tabsolutePath,\n\t\t\t\t\t\tremappings: result.nodePathRemappings,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t});\n\t\t\tif (nodePathMutation === null) {\n\t\t\t\tthrow new Error('Could not reorder sequence');\n\t\t\t}\n\n\t\t\treturn {success: true, nodePathMutation};\n\t\t} catch (error) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\treason: error instanceof Error ? error.message : String(error),\n\t\t\t\tstack: error instanceof Error && error.stack ? error.stack : '',\n\t\t\t};\n\t\t}\n\t};\n\n\tconst keyframes: BrowserStudioKeyframeOperations = {\n\t\taddSequenceKeyframe: async (request) => {\n\t\t\tconst result = await commitKeyframeMutations({\n\t\t\t\tlabel: `${request.key} keyframe`,\n\t\t\t\tsequenceMutations: [\n\t\t\t\t\t{","sourceCodeStart":1528,"sourceCodeEnd":1564,"githubUrl":"https://github.com/remotion-dev/remotion/blob/b2f4e34732f3c6c222ea029413e22dc402218cd7/packages/browser-studio/src/browser-studio-operations.ts#L1528-L1564","documentation":"Returned as `{success: false, reason: 'Could not reorder sequence'}` by reorderSequence in @remotion/browser-studio. The reorder codemod itself ran and produced new file contents, but `controller.applyMutation(...)` with the node-path remapping list returned null, meaning the project controller could not apply the mutation plus remappings to its tracked state. This almost always means the node paths being remapped no longer line up with what the controller expects (stale paths after a concurrent or prior edit).","triggerScenarios":"Calling `reorderSequence({fileName, sourceNodePath, targetNodePath, position})` with node paths captured before another mutation changed the file; reordering while a previous mutation's remappings were not yet applied; passing a fileName that resolves to a file whose tracked state diverged from `project.files`.","commonSituations":"Drag-and-drop reorder in a custom timeline UI where the client cached node paths from an earlier render; two edits racing in the same session; hot-reload or undo/redo leaving the client's node paths stale.","solutions":["Re-fetch current node paths (re-read the sequence structure after every mutation) and retry the reorder with fresh paths","Verify the fileName exists via findProjectFile-style lookup before calling","Sequence your mutations so only one runs at a time (await each operation before computing the next node paths)","If it reproduces with freshly fetched paths on an unmodified project, capture the file contents and report it as a Browser Studio bug"],"exampleFix":"// before\nawait operations.reorderSequence({\n  fileName,\n  sourceNodePath: cachedSourcePath, // captured before last edit\n  targetNodePath: cachedTargetPath,\n  position: 'before',\n});\n\n// after\n// always re-derive paths from the latest state before mutating\nconst fresh = await operations.getSequenceData(/* current file */);\nconst result = await operations.reorderSequence({\n  fileName,\n  sourceNodePath: fresh.source,\n  targetNodePath: fresh.target,\n  position: 'before',\n});\nif (!result.success) {\n  // refresh UI state from project and let the user retry\n}","handlingStrategy":"validation","validationCode":"const res = await operations.reorderSequence({fileName, sourceNodePath, targetNodePath, position});\nif (!res.success) {\n  // res.reason === 'Could not reorder sequence': paths are stale\n  await resyncNodePathsFromProject();\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Re-read node paths from project state immediately before each mutation","Serialize mutations: await one before computing inputs for the next","Treat any success:false with this reason as 'stale state' — refresh, then let the user retry"],"tags":["node-path","sequence","mutation","browser-studio"],"backgroundTag":"invalid-node-path","analyzedSha":"b2f4e34732f3c6c222ea029413e22dc402218cd7","analyzedAt":"2026-08-22T21:45:17.748Z","contentChangedAt":"2026-08-22T21:45:17.748Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}