{"record":{"id":"7429547f0af3a06a","repo":"slidevjs/slidev","slug":"slide-anchorno-is-out-of-sync-with-its-source-f","errorCode":null,"errorMessage":"Slide ${anchorNo} is out of sync with its source file. Try again.","messagePattern":"Slide (.+?) is out of sync with its source file\\. Try again\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/slidev/node/mcp/operations.ts","lineNumber":200,"sourceCode":"    throw new Error(\n      `Cannot move a slide across markdown files: slide ${from} is in \"${slide.source.filepath}\" `\n      + `but slide ${anchorNo} is in \"${anchor.source.filepath}\" (imported with \\`src:\\`). `\n      + `Move it within its own file, or edit the \\`src:\\` imports in the entry file manually.`,\n    )\n  }\n\n  assertNotEntryHeadmatter(data, slide.source, 'move')\n  if (before != null)\n    assertNotEntryHeadmatter(data, anchor.source, 'insert a slide before')\n\n  const md = getMarkdown(data, slide.source)\n  const fromIdx = md.slides.indexOf(slide.source)\n  if (fromIdx < 0)\n    throw new Error(`Slide ${from} is out of sync with its source file. Try again.`)\n  md.slides.splice(fromIdx, 1)\n  const anchorIdx = md.slides.indexOf(anchor.source)\n  if (anchorIdx < 0)\n    throw new Error(`Slide ${anchorNo} is out of sync with its source file. Try again.`)\n  md.slides.splice(before != null ? anchorIdx : anchorIdx + 1, 0, slide.source)\n  const fileContent = await parser.save(md)\n  return { moved: slide, anchor, filepath: md.filepath, fileContent }\n}\n","sourceCodeStart":182,"sourceCodeEnd":205,"githubUrl":"https://github.com/slidevjs/slidev/blob/0d798ace5828966d9f77f62094d5f7a971ad98f7/packages/slidev/node/mcp/operations.ts#L182-L205","documentation":"Thrown by moveSlide when md.slides.indexOf(anchor.source) < 0 after the 'from' slide was already spliced out, i.e. the anchor slide's SourceSlideInfo is not in its file's slides array. Same consistency-guard family as the from-side check; indicates the anchor's source object is stale.","triggerScenarios":"Calling moveSlide where the anchor (before/after) slide's source is no longer a member of md.slides, typically because external edits invalidated the object reference between getData() and the call.","commonSituations":"Concurrent edits to the anchor's file; stale getData() snapshot; anchor imported via src: from a file that was modified.","solutions":["Re-fetch data via ctx.getData() right before moveSlide and retry.","Confirm the anchor slide still exists via slidev-list-slides before reissuing the move.","Prevent concurrent writers on the same markdown file."],"exampleFix":"// before: anchor reference stale after an external edit\nconst data = await ctx.getData()\nawait moveSlide(data, { from: 2, before: 5 }) // throws: anchor out of sync\n\n// after: refresh and re-resolve anchor\nconst data = await ctx.getData()\nawait moveSlide(data, { from: 2, before: 5 })","handlingStrategy":"retry","validationCode":"function anchorSlideInFile(md: { slides: SourceSlideInfo[] }, source: SourceSlideInfo): boolean {\n  return md.slides.indexOf(source) >= 0\n}\n\n// before moveSlide, validate the anchor too:\nconst anchor = resolveSlide(data, before ?? after!)\nconst md = data.markdownFiles[anchor.source.filepath]\nif (!md || !anchorSlideInFile(md, anchor.source)) return // refresh","typeGuard":"function anchorSourceCurrent(md: { slides: SourceSlideInfo[] }, s: SourceSlideInfo): s is SourceSlideInfo {\n  return md.slides.indexOf(s) >= 0\n}","tryCatchPattern":"try {\n  return await moveSlide(data, opts)\n} catch (e) {\n  const anchorNo = opts.before ?? opts.after\n  if (e instanceof Error && new RegExp(`Slide ${anchorNo} is out of sync`).test(e.message)) {\n    data = await ctx.getData()\n    return await moveSlide(data, opts)\n  }\n  throw e\n}","preventionTips":["Validate both from and anchor sources against their file's slides array before splicing.","Refresh ctx.getData() per mutation.","Serialize writers per markdown file.","After any external edit, reload and re-list before reissuing the move."],"tags":["mcp","state","stale-data","move","consistency"],"backgroundTag":null,"analyzedSha":"0d798ace5828966d9f77f62094d5f7a971ad98f7","analyzedAt":"2026-08-12T17:10:56.221Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}